If you’re writing a 3D game, or a VFX simulator, or even trying to solve a 3D kinematics equation, you need to be able to compute how objects react to forces; in particular how they will spin. The mathematics of spinning objects can be quite complicated and subtle, and in this series I will attempt to make the concepts clear.
Let’s start with 2D spinning objects
If you’ve taken high school or college physics, you’ve probably somewhat familiar with how rotation works about a fixed axis: Apply a little bit of torque (twisting force), and the object starts to spin. Apply the opposite torque, and it slows down until it reverses. This animation from Wikipedia shows it nicely enough:
A little key for what the arrows stand for:
Symbol | Meaning |
---|---|
r | Direction from the axis to the point of applied force |
F | Applied (linear) force |
τ | Torque (twisting force) |
p | Linear momentum |
L | Angular (rotational) momentum |
Wait, why are we using vectors
You’re right; In 2D, we don’t really need vectors; we could just use numbers. But since we’ll be moving on to 3D, let’s get used to our quantities being vector-valued.
Moving on
This is a little abstract, so let’s use a more concrete example. Since this is the internet, what better way to illustrate this than with a cat gif?
Here, the cat is making the toilet paper roll spin— and he’s doing it by applying a downward force with his paw. This downward force is converted to twisting force— torque— by the fact that the toilet roll can spin freely about a fixed axis, but not move freely in space (otherwise, he’d be batting it across the floor).
We compute the amount of twisting force that Mittens here is applying by taking the cross product of the downward force F with a vector r connecting the cat’s paw to the toilet paper axis:
τ = r ⨯ F
What this means: Twisting force is stronger with more force, and longer lever arm. The axis of twisting force is perpendicular to the force applied.
Note that for a fixed axis, we must take the part of the force vector which is orthogonal to the axis. Since the roll is held in place from left to right, there can be no net force along this direction. We may need to adjust an applied force to ensure this:
Forthogonal = F – (F · â) â
(â is the unit-length fixed axis)
From the above equations, it may also be apparent that the torque vector is always aligned with the rotation axis, since F and r are defined to be perpendicular to it. (This is not so for free rotation, but we will get to that later). The length of the torque vector shows how much twisting force is being applied, and therefore how quickly the toilet roll is going to spin up.
Using the knowledge that our vectors are perpendicular, we can come up with a simplified scalar version of τ = r ⨯ F. We’ll also make use of the identity that |a x b| = |a||b|sin(θ):
τ = r ⨯ F
|τ| = |r||F|sin(90°)
|τ| = |r||F|
Intuitively, this should all make some sense: You can get more twisting force by using a wrench with a long handle, or better yet, a cheater bar (which is a length of pipe you use to extend a wrench handle), when compared to using your hand. The wrench has much longer r than the bolt you’d be grabbing.
The integral of torque is the angular momentum, which is a vector describing how the mass of the object is currently spinning. It is aligned with the axis about which the mass is spinning.
L(t) = ∫τ(t) dt
What this means: The longer you apply torque, the more rotational inertia your object will have.
After Mittens has applied some torque for a short moment, that integral will be nonzero, and the toilet roll will be spinning:
In the absence of friction, the inertia of the roll will keep it spinning indefinitely. In reality, the roll will rub against the mount and come to a stop after a short time. This tells us that friction can exert torque too!
OK, so that’s great, but if we were coding a game (a cat toilet-roll simulator? See you at the top of the casual gaming charts), how would you compute the position of the toilet roll at each instant of time? Put another way, if I know how hard Mittens/the player swats the roll, and how for how long, can we figure out how much toilet paper has unrolled?
For a fixed rotation axis (like our toilet roll mounted to the wall), the connection between angular momentum and rotation rate ω is pretty simple: There is a factor which relates the two called the moment of inertia, I, which describes the object’s resistance to being spun:
ω(t) = dθ / dt = |L(t)| / I (2D rotation)
What this means: The rate of rotation of the toilet roll is proportional to the length of the angular momentum vector. The larger the moment of inertia, the more slowly the roll will spin.
The moment of inertia is computed based on the mass of the object and its distribution about the axis of rotation. More on this later.
From this we can very easily figure out the absolute angle by integrating the rate of rotation:
θ(t) = ∫ω(t) dt
What this means: The rotation angle at any point in time is the cumulative total of the rate of rotation up to that moment.
To this I will add two more equations involving the angular acceleration, α:
α(t) = d/dt ω(t)
τ(t) = I α(t)
Putting it all together
Now we have enough to make a complete picture of 2D rotation:From this diagram, you can figure out how to relate any aspect of rotation to any other at a glance.
I find this much easier to understand and navigate than a set of written equations; this way it’s clear how the information flows. You could start at the bottom with information about torque, work your way up, and figure out how the object is oriented; or you could start at the top with a changing angle, work downwards, and figure out what the torque is. Because there are some redundant equations, you even have a choice of paths/methods!
Neat!
But all of this is useless for 3D
OK, well, not useless. It’s really pretty important that all the above makes sense so that we can understand things when we get to 3D. And believe me, dear reader, it gets crazy. Take a look at the video, taken on the International Space Station, which inspired me to try and simulate 3D rotational dynamics in the first place:
What. The. Hell.
What’s going on here? I assure you that there is nothing special about that handle; there are no tiny rockets on it, or fluid inside, or anything else weird. It’s just a T-shaped thing. Nothing is touching it to make it flip like that, so there cannot be any torque. What the hell is happening?
I’ll give a little preview of things to come: This phenomenon is called torque-free precession. You rarely see it on Earth because most of the spinny-things you deal with from day to day are fixed to axles, and are governed by the simple equations above.
More complicated cases like spinning tops still have some amount of torque applied, because they are resting on a surface like a table, and the weight of the top tries to tip it over. Pretty much only in free fall or zero-G can you see something precisely like the above, so not surprisingly, we Earth-bound humans have zero intuition for it.
To begin understanding how we can simulate the physics of the T-handle, we’ll have to wait for the next installment!
Are you going to continue this using 3D vectors? Quaternions? OpenGL style projective geometry methods?
Your writings and pictures are really clear and funny. I just enjoyed your Kalman Filter explanation. In a quid pro quo, I offer that you read up on Geometric Algebra’s version of Conformal geometry. As you might have deduced from the questions above, each increase in sophistication gives rise to much more interesting, efficient and physically sensible results. That is, using 3D vectors is simplest to understand, but you are stuck with special case of 3D (no cross product except 3D and 7D) with no recourse to expanded understanding, and even then you will have practical issues like gimbal lock. Upgrading to quaternions give you the cosine half-angle, that serves as a check for consistency normally, and completely safes the day on gimbal lock. But even quaternions are limited; Geometric Algebra is needed to specify the full richness of geometrical niceness.
The next upgrade to OpenGL style methods is not even intuitive, and is only brilliant upon hindsight. But the hints are with quaternions—having one extra “dimension” to hide some checks and balances is practically helpful, so why not add more? Indeed, adding an extra dimension, point at infinity, and shifting the origin away from numerical zero, allows us to handle origin issues too. The brilliance comes from realising that this formalism then allows us to express lines and circles in the same way (which is then turned around to complain that old 3D Cartesian geometry failed to have a unified description for lines and circles, and planes and spheres). Going one more dimension, we get Conformal geometry in GA, very different from conformal geometry elsewhere in maths and physics, but with the same essential idea: absolute lengths are gone, even more unity and sense, yet more improvements to OpenGL computations, and so forth.
Enjoy!
I have to agree with xiaokj about geometric algebra.
I highly highly recommend you read David Hestenes’s book *New Foundations for Classical Mechanics*. http://geocalc.clas.asu.edu/html/NFCM.html
It has the best explanation of precession and rigid body dynamics, &c. that I’ve seen anywhere.
I loved this intro to the subject of rotation. That video of the T-handle is crazy. I can see how it would be inspiring to work on your rotation project. It got me inspired to read the next installment of this. I hope that’ll happen some day.