0
$\begingroup$

I'm making a spaceship piloting game, and I'm trying to make the movement follow the laws of physics. The ship is able to control it's angular acceleration in pitch, yaw, and roll. The way I've implemented it, the ship rotates around it's local x, y, and z axis, however, I'm having a hard time wrapping my head around rotations in 3D to verify if this kind of movement is actually accurate.

For example, take the following scenario. From the perspective of the pilot, I'm yawing left at some angular speed x. If I look at the ship from outside in a "top down" (top relative to the pilot), I would see the ship rotating CCW with angular speed x. Then, let's say I roll clockwise 180 degrees from the perspective of the pilot. Here's where things get a bit trippy to me. My intuition, and what happens in game, both produce the following result: From the pilot's perspective, the ship is still yawing left at the same speed x. However, from the "top down" perspective, the ship would appear to be rotating CW with speed x. So, a 180 degree roll changed the ships rotation from CCW to CW. Does that make sense? Is angular momentum conserved here? So in a sense the way I've implemented it makes intuitive sense to the pilot (if I'm yawing left, and I do some rotation in another axis, my yaw shouldn't be affected so I should still be yawing left). However, to an "outside" perspective, this makes it look as if the ship is just sometimes randomly reversing rotational direction. On the other hand, if I make it intuitive for the outside perspective, in the earlier example I gave, the ship would instead be yawing right for the pilot after the roll maneuver, which would make it continue rotating CCW; making more sense to the "top down" view, but being trippier for the pilot.

I was really intrigued by this so I went to look for a physical example. I took a skateboard wheel and spun it so that it was spinning CCW, then flipped the board over, and indeed the wheel was now spinning CW to me. Still, this seems really suspicious to me, and I'm worried there may be a difference between the wheel and a spaceship, given that the first one is fixed on an axis, and the second one is just freely rotating in space.

Restating my question again, is it realistic for a 180 degree roll to seemingly reverse the rotation direction of a yaw movement?

Or more generally, is the case where the movement makes intuitive sense to the pilot the correct one? Or should it follow the intuition of the outside perspective?

(I'm not a physics person, so please don't be too hard on me if I've used some terminology wrong, hopefully my explanation makes my question clear even if the terminology is wrong)

$\endgroup$
6
$\begingroup$

Roll Pitch and Yaw are common names for 3 angles used to describe orientation. There's actually a lot of ways they can combine. At the top level you have Euler Angles vs Tait-Bryan Angles, which refer to which axes you rotate around at a very high level (xyx vs. xyz). The confusion starts right there, as most aircraft use yaw-pitch-roll as Tait-Bryan angles, but people will use the name "euler angles" to describe them! Beyond these 2 categories, there are dozens to over a thousand of ways they can be combined depending on how you phrase the question and which things you are willing to vary (in particular, whether you are willing to change the order of the 3 axes or not and whether you allow the axes to point in the opposite direction).

The key to working with them is to understand that they are actually describing an orientation. The individual values themselves obey strange rules which are borderline non-physical. For example, in your case where you are yaw-ing CW, and then roll 180 degrees, in the real world your orientation will keep changing the same way it did before, but the numeric value for yaw will have flipped its sign. This is okay. It obeyed the conservation laws, even though yaw could be discontinuous in its sudden jump!

Euler angles are almost never actually used for equations of motion or interpolation. They're terrible at it because they behave borderline non-physical. For instance, if you try to rotate smoothly from one orientation to another just by linearly interpolating the yaw pitch and roll channels, you find the object takes a rather exotic looking path to get to its final orientation. They're convenient for a quick way to describe an orientation in a physically meaningful way, but they act squirely when you start to vary them over time.

If you want to have things like a rate of change of orientation, use a orientation format which supports that better. Direction Cosine Matrixes and Quaternions have far superior properties. From my experience, quaternions are by far the most popular way to handle rotations, although it takes a while to wrap your head around them. Both of them have straightforward ways of dealing with the conservation of angular momentum.

If you want a sense of how wonky euler angles can be, look at gimbal lock. This is a quirky situation where two of the axes generate the same rotation. It happens when the second rotation rotates the third rotation into the same axis as the first rotation. This is a major issue with gimbals because, when it occurs, you end up with one rotational dimension that you simply cannot observe. This means that once gimbal lock occurs, you no longer know what your orientation is.

We nearly failed to go to the moon because of this. Apollo 11 had a standard 3 ring gyro, so was susceptible to gimbal lock. To combat this, they had a clever little "kicker" device which would rotate one of the axes at a critical moment to sidestep this horrid alignment from occuring. As it so happened, the code to handle this had a bug, and caused the subsystem to cease operating. They flew onward knowing the risk that a gimbal lock would cause them to lose track of their attitude. (Contingency plans included re-acquiring alignment by observing stars, which would be slow and error prone, but would get astronauts home safely).

There is a 4 ring gyro design which is immune to these issues. However, at the time, the development of the hardware would have pushed the schedule too hard, so they stuck with the simpler 3 ring gyro. Pilot Mike Collins had some choice words about this in flight:

104:59:35 Garriott: Columbia, Houston. We noticed you are maneuvering very close to gimbal lock. I suggest you move back away. Over.
104:59:43 Collins: Yeah. I am going around it, doing a CMC Auto maneuver to the Pad values of roll 270, pitch 101, yaw 45.
104:59:52 Garriott: Roger, Columbia. (Long Pause)
105:00:30 Collins: (Faint, joking) How about sending me a fourth gimbal for Christmas.

Also, a shout out to screw theory. While a spaceship simulator tends to use positions and quaternions, screw theory combines the two into one 6 dimensional concept: the screw. This is popular in robotics because you have 6 dimensions of freedom and a 6-element vector. This makes it easier to do "inverse kinematics" where you try to achieve a particular positioning of a tool using all of the joints of a robotic arm. It's easier because there's natural concepts of "inverting" a joint rotation which are less natural when you break things up into positions and orientations.

$\endgroup$
1
  • 1
    $\begingroup$ after working with spacecraft guidance and control, I realized the only reason to use Euler angles is that you want the inverse transformation and don't have a computer. I suppose that's why Euler used them. We have computers: Use Trait-Bryan angles. $\endgroup$ – JEB Nov 17 '20 at 4:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.