Great ideas, nescalona. I edited the tutorial and included them. Thanks!![]()
My programs: BIOS - Alcyone - Calculator - Notepad - Movie Player
My tutorials: applyTorque - Quaternions - PID controllers
Some other things I made: FT Chip - RK4 Solar System
Gimbal had me locked up tight, but you saved me!
Thank you dear sir!
i I am trying to make VTOL, but i am having trouble making side thrusters, when I press W, to set roll to 45 and when unpress to go back to 0, when I tried with
setAng, it was spinning into 1side of the map.
I understand torque pretty well (though what is the difference between a moment and toque? is a moment more like applyOffsetForce():? I know a moment is F*D where d is the distance from the point you are taking the moment about and F is force applied perpendicularly to the distance D, and the moment acts about an axis perpendicular to the plane the force vector and the distance create, AKA cross product.)
But what benefits does using applyToque(): have over using applyAngForce():? Why use one or the other instead of the alternative? I have had lots of issues with applyAngForce freaking out on my prop and I was hoping that maybe the answer to this would enlighten me as to why. Seriously, getting a 2x2 phx box to simply stay upright, adjust its bearing to face something, and tilt to have a certain angle so I can mount a pewpew gun on it is extremely difficult, without the right constants, it basically sends the prop into a complete spaz every time.
The difference between a moment and torque is that torque is a couple; two forces of equal magnitude in opposite directions acting on one object.
The only real difference is that torque rotates without adding any linear velocity, whereas an offset force or a moment that doesn't have an opposing force will add linear velocity as well as rotational.
applyTorque doesn't suffer from gimbal lock like applyAngForce can, due to it not using angles.
That depends entirely on how you use each of them. Both applyTorque & AngForce use a pseudo vector input 'V';
V is a vector in either the (p, y, r) or (x, y, z) co-ordinate system that describes a 3d unit length axis of rotation, multiplied by a scalar magnitude.Code:applyTorque(V) # is equivalent to applyAngForce(ang(shiftR(V)))
As you can see, ang(pitch, yaw, roll) maps to vec(rotate about local x, rotate about local y, rotate about local z) with a left shift, hence the equivalence shown in the code above.
This pseudo vector (Euler angle) is fine for specifying a torque, but not sufficient for fully dealing with 3d rotations, since with Euler angles; V =/= Va + Vb, where Va is a rotation (direction vector), Vb is a subsequent rotation (direction vector), and V is the position vector describing the sum of the two rotations. Ergo, rotation concatenation is not possible with Euler angles.
Therefore, other rotation representations such as matrices or quaternions must be used to deal with rotations in a complete, general manner. If you calculate the required rotation using either of these methods, and then calculate the (Euler angle) torque, either applyTorque or angForce can be used with no gimbal lock issues at all.
TLDR: If you're having gimbal lock problems I feel bad for you son, I've got 99 problems but 3d Euler angle non-commutativity is not one.
Last edited by Tolyzor; 2 Weeks Ago at 06:00 AM.
Comprehensive Gmod physics guide - Ballistic trajectory with drag - Autodyno engine performance test
Don't make the mistake these skydivers did and use any of my Gmod physics models for real life situations...
If applyTorque operates the same way torque works in the real world, this is completely false. And, in any case, you've effectively described an object at rest (or at constant velocity, but any object inherently requires unbalanced forces to move anyways). Any two forces of equal and opposite magnitude cancel. Newton's First Law says that objects at rest remain at rest unless there are unbalanced forces. If what you've described was actually happening, the forces would be balanced, and there'd be no motion.
Torque is the product of a force that is acted upon an object perpendicular to the axis about which it rotates and the radius. Alternatively, if the force is known and the angle relative to the vertical is known, then this is a component of the perpendicular force. Use the formula: t=r*F*sin(theta)
I still don't see the advantages of applytoque vs applyangforce?
Also, when using quaternions, do you simply use quat() instead of vec() and do the rest of the math the same? Can't you jsut avoid gimbal lock with E:toLocal(angles)?
Last edited by elseagoat; 2 Weeks Ago at 08:33 PM.
Bookmarks