The Relationship Between Unit Vector Rotations and Euler Angle Functions
Total Page:16
File Type:pdf, Size:1020Kb
1 The Relationship between Unit Vector Rotations and Euler Angle Functions
Jed Margolin
In my article Unit Vector Math for 3D Graphics I show a geometric model where there is a Universe filled with Objects, each of which is free to rotate and translate. Each Object may look at the Universe or any other Object, and each Object will always rotate around its own axes regardless of its (or the Observer's) orientation.
In the field of aerodynamic modeling (and in computer graphics in general) the method used to do this is to generate functions of Euler Angles. What this means is, "How do I rotate an Object in my frame of reference so that it will appear to rotate in its frame of reference?"
These functions are:
dxa = TAN(ya) COS(xa) dsza + TAN(ya) SIN(xa) dsya + dsxa
dya = -SIN(xa) dsza + COS(xa) dsya
dza = COS(xa) dsza + SIN(xa) dsya ------COS(ya)
where: za = Euler angle, rotation around z axis (in World coordinates) dza = incremental rotation around z axis (in World coordinates)
ya = Euler angle, rotation around y axis (in World coordinates) dya = incremental rotation around y axis (in World coordinates)
xa = Euler angle, rotation around x axis (in World coordinates) dxa = incremental rotation around x axis (in World coordinates)
dsza = incremental rotation angle around z axis in Ship coordinates (Yaw)
dsya = incremental rotation angle around y axis in Ship coordinates (Pitch)
dsxa = incremental rotation angle around x axis in Ship coordinates (Roll)
After applying an incremental rotation you need to update za, ya, and xa so that: za' = za + dza ya' = ya + dya xa' = xa + dxa 2
Euler angle rotations suffer from a number of problems, one of which is that when the object is pointing directly along one of the axes, the equation blows up. In this case, it blows up when ya=90 degrees. (If it's any comfort, you get to choose which axis blows up.)
In this article I will show the relationship between Unit Vector Math and Euler Angle Functions by finding the functions to relate incremental rotations around the Ship axes to rotations around the World axes (the Euler angles). xa' = xa + dxa where dxa = F1(xa,ya,za,dsxa,dsya,dsza) ya' = ya + dya where dya = F2(xa,ya,za,dsxa,dsya,dsza) za' = za + dza where dza = F3(xa,ya,za,dsxa,dsya,dsza)
As before, the definitions are:
za = Euler angle, rotation around z axis (in World coordinates) dza = incremental rotation around z axis (in World coordinates)
ya = Euler angle, rotation around y axis (in World coordinates) dya = incremental rotation around y axis (in World coordinates)
xa = Euler angle, rotation around x axis (in World coordinates) dxa = incremental rotation around x axis (in World coordinates)
dsza = incremental rotation angle around z axis in Ship coordinates (Yaw)
dsya = incremental rotation angle around y axis in Ship coordinates (Pitch)
dsxa = incremental rotation angle around x axis in Ship coordinates (Roll)
We are looking for the functions to relate incremental rotations around the Ship axes to rotations around the World axes (the Euler angles). xa' = xa + dxa where dxa = F1(xa,ya,za,dsxa,dsya,dsza) ya' = ya + dya where dya = F2(xa,ya,za,dsxa,dsya,dsza) za' = za + dza where dza = F3(xa,ya,za,dsxa,dsya,dsza) 3
It will probably be easier if we separate dsxa, dsya, dsza so that:
For dsxa there are three functions:
xa' = xa + G1(xa,ya,za,dsxa) ya' = ya + G2(xa,ya,za,dsxa) za' = za + G3(xa,ya,za,dsxa)
For dsya there are three functions:
xa' = xa + G4(xa,ya,za,dsya) ya' = ya + G5(xa,ya,za,dsya) za' = za + G6(xa,ya,za,dsya)
For dsza there are three functions:
xa' = xa + G7(xa,ya,za,dsza) ya' = ya + G8(xa,ya,za,dsza) za' = za + G9(xa,ya,za,dsza)
If we can find the separate functions we can combine them later.
Rotations:
Yaw X' = X COS(za) - Y SIN(za) [Equation 1] Y' = X SIN(za) + Y COS(za)
Pitch Z' = Z COS(ya) - X SIN(ya) [Equation 2] X' = Z SIN(ya) + X COS(ya)
Roll Y' = Y COS(xa) - Z SIN(xa) [Equation 3] Z' = Y SIN(xa) + Z COS(xa) 4
Consolidating Equations 1, 2, and 3 for a motion consisting of rotations za, ya, xa (Yaw, Pitch, Roll in that order) yields:
X" = [ COS(ya) COS(za) ] X + [-COS(ya) SIN(za)] Y + [SIN(ya)] Z
Y" = [ SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za)] X + [-SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za)] Y + [-SIN(xa) COS(ya)] Z
Z" = [-COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za)] X + [ COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za)] Y + [COS()xa COS(ya)] Z
The Matrix Form is: Ax Ay Az Bx By Bz Cx Cy Cz
Where:
Ax = COS(ya) COS(za)
Ay = -COS(ya) SIN(za)
Az = SIN(ya)
Bx = SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za)
By = -SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za)
Bz = -SIN(xa) COS(ya)
Cx = -COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za)
Cy = COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za)
Cz = COS(xa) COS(ya) xa, ya, za are called the Euler Angles. 5 Ship Yaw
We want to find out how the Euler angles are changed if we yaw the Ship in its coordinate system.
1.1 Start with Euler equations:
Ax = COS(ya) COS(za) Ay = -COS(ya) SIN(za) Az = SIN(ya)
Bx = SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za) By = -SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za) Bz = -SIN(xa) COS(ya)
Cx = -COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za) Cy = COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za) Cz = COS(xa) COS(ya)
1.2 Transform it to the Ship Frame of Reference
Ax = COS(ya) COS(za) Bx = -COS(ya) SIN(za) Cx = SIN(ya)
Ay = SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za) By = -SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za) Cy = -SIN(xa) COS(ya)
Az = -COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za) Bz = COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za) Cz = COS(xa) COS(ya) 6
1.3 Yaw Ship by angle dsza
Ax' = Ax COS(dsza) - Ay SIN(dsza) Ay' = Ax SIN(dsza) + Ay COS(dsza) Az' = Az
Bx' = Bx COS(dsza) - By SIN(dsza) By' = Bx SIN(dsza) + By COS(dsza) Bz' = Bz
Cx' = Cx COS(dsza) - Cy SIN(dsza) Cy' = Cx SIN(dsza) + Cy COS(dsza) Cz' = Cz
Therefore:
Ax' = [ COS(ya) COS(za)] COS(dsza) - [SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za)] SIN(dsza)
Ay' = [ COS(ya) COS(za)] SIN(dsza) + [SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za)] COS(dsza)
Az' = [-COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za)]
Bx' = [-COS(ya) SIN(za)] COS(dsza) - [-SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za)] SIN(dsza)
By' = [-COS(ya) SIN(za)] SIN(dsza) + [-SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za)] COS(dsza)
Bz' = COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za)
Cx' = [ SIN(ya)] COS(dsza) - [-SIN(xa) COS(ya)] SIN(dsza)
Cy' = [SIN(ya)] SIN(dsza) + [-SIN(xa) COS(ya)] COS(dsza)
Cz' = COS(xa) COS(ya) 7
1.4 Transform it back to Universe Coordinates:
Ax' = [ COS(ya) COS(za) ] COS(dsza) - [ SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za) ] SIN(dsza)
Bx' = [ COS(ya) COS(za) ] SIN(dsza) + [ SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za) ] COS(dsza)
Cx' = [-COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za)]
Ay' = [-COS(ya) SIN(za)] COS(dsza) - [-SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za)] SIN(dsza)
By' = [-COS(ya) SIN(za)] SIN(dsza) + [-SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za)] COS(dsza)
Cy' = COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za)
Az' = [SIN(ya)] COS(dsza) - [-SIN(xa) COS(ya)] SIN(dsza)
Bz' = [SIN(ya)] SIN(dsza) + [-SIN(xa) COS(ya)] COS(dsza)
Cz' = COS(xa) COS(ya) 8
1.5 We are looking for the dza, dya, dxa that give this same result.
Find dya as a function of dsza:
Az = SIN(ya) [From Section 1.1]
Az' = SIN(ya+dya)
= SIN(ya) COS(dya) + COS(ya) SIN(dya) [Trigonometric Expansion]
This must be equal to the Az' obtained by Yawing the Ship.
Az' = [SIN(ya)] COS(dsza) - [-SIN(xa) COS(ya)] SIN(dsza) [From Section 1.4]
Therefore
SIN(ya) COS(dya) + COS(ya) SIN(dya) = [SIN(ya)] COS(dsza) - [-SIN(xa) COS(ya)] SIN(dsza)
Assuming dya and dsza are small: COS(dya)=1, SIN(dya)=dya, COS(dsza)=1, SIN(dsza)=dsza
SIN(ya) + COS(ya)(dya) = SIN(ya) - [-SIN(xa)COS(ya)](dsza) so that:
COS(ya)(dya) = SIN(xa) COS(ya) (dsza)
(dya) = SIN(xa) COS(ya) (dsza) ------COS(ya)
The result is that:
dya = dsza SIN(xa) [Equation 4] 9
Find dza as a function of dsza:
Ax = COS(ya) COS(za) [from Section 1.1]
Ax' = COS(ya+dya) COS(za+dza)
= [COS(ya)COS(dya) - SIN(ya)SIN(dya)] * [COS(za)COS(dza)- SIN(za)SIN(dza)] [Trigonometric expansion]
Assuming dya, dza are small:
Ax' = [COS(ya)- SIN(ya)(dya) ] [COS(za)- SIN(za)(dza)]
= COS(ya)COS(za)- SIN(ya)(dya)COS(za)- SIN(za)(dza)COS(ya) + SIN(ya)(dya)SIN(za)(dza)
Since dya, dza are small the last term {SIN(ya) (dya) SIN(za) (dza)} is approximately zero, so that:
Ax' = COS(ya)COS(za)- SIN(ya)COS(za)dya - SIN(za)COS(ya)dza
This must be equal to the Ax' obtained by Yawing the Ship.
Ax' = COS(ya)COS(za)COS(dsza) - [SIN(xa)SIN(ya)COS(za)+ COS(xa)SIN(za)] SIN(dsza) [from Section 1.4]
= COS(ya)COS(za)COS(dsza) - SIN(xa) SIN(ya) COS(za) SIN(dsza) + COS(xa) SIN(za) SIN(dsza)
Assuming dya, dza are small:
Ax' = COS(ya)COS(za) - SIN(xa)SIN(ya)COS(za)dsza + COS(xa)SIN(za)(dsza)
Therefore:
COS(ya)COS(za) - SIN(ya)COS(za)dya - SIN(za)COS(ya)dza = COS(ya)COS(za) - SIN(xa) SIN(ya) COS(za) dsza + 10 COS(xa) SIN(za) dsza
Cranking through it:
SIN(ya) COS(za) dya - SIN(za) COS(ya) dza =
-SIN(xa) SIN(ya) COS(za) dsza + COS(xa) SIN(za) dsza
From Equation 4, dya = dsza SIN(xa)
Therefore
-SIN(ya) dsza SIN(xa) COS(za) - SIN(za)COS(ya) dza = -SIN(xa) SIN(ya) COS(za) dsza + COS(xa) SIN(za) dsza
-SIN(za) COS(ya) dza = -SIN(xa) SIN(ya)COS(za) dsza + COS(xa) SIN(za) dsza - SIN(ya) dsza SIN(xa) COS(za)
= -SIN(xa) SIN(ya)COS(za) dsza + SIN(ya) dsza SIN(xa) COS(za) + COS(xa) SIN(za) dsza
= -SIN(xa) SIN(ya)COS(za) dsza + SIN(ya) SIN(xa) COS(za) dsza + COS(xa) SIN(za) dsza
= COS(xa) SIN(za) dsza
dza = -COS(xa) SIN(za) dsza ------SIN(za) COS(ya)
The result is that:
dza = -COS(xa) dsza ------[Equation 5] COS(ya) 11 Find dxa as a function of dsza:
Cz = COS(xa) COS(ya) [from Section 1.1]
Cz' = COS(xa+dxa) COS(ya+dya)
= [ COS(xa) COS(dxa) - SIN(xa) SIN(dxa) ] * [ COS(ya) COS(dya) - SIN(ya) SIN(dya) ] [Trigonometric Expansion]
Assuming dxa, dya are small:
Cz' = [ COS(xa) - SIN(xa) dxa ] [ COS(ya) - SIN(ya) dya ]
= COS(xa) COS(ya) - COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) dya + SIN(xa) dxa SIN(ya) dya
Since dxa, dya are small the last term {SIN(xa) dxa SIN(ya) dya} is approximately zero.
Cz' = COS(xa) COS(ya) - COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) dya
This must be equal to the Cz' obtained by Yawing the Ship.
Cz' = COS(xa) COS(ya) [From Section 1.4]
Therefore:
COS(xa) COS(ya) = COS(xa) COS(ya) - COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) dya
Cranking through it: 0 = - COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) dya
From Equation 4, dya = dsza SIN(xa) 0 = - COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) dsza SIN(xa)
COS(ya) SIN(xa) dxa = - COS(xa) SIN(ya) dsza SIN(xa)
dxa = - COS(xa) SIN(ya) dsza SIN(xa) ------COS(ya) SIN(xa)
The result is that:
dxa = - COS(xa) TAN(ya) dsza [Equation 6] 12
Ship Pitch
We want to find out how the Euler angles are changed if we pitch the Ship in its coordinate system.
2.1 Start with Euler equations:
Ax = COS(ya) COS(za) Ay = -COS(ya) SIN(za) Az = SIN(ya)
Bx = SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za) By = -SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za) Bz = -SIN(xa) COS(ya)
Cx = -COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za) Cy = COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za) Cz = COS(xa) COS(ya)
2.2 Transform it to the Ship Frame of Reference
Ax = COS(ya) COS(za) Bx = -COS(ya) SIN(za) Cx = SIN(ya)
Ay = SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za) By = -SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za) Cy = -SIN(xa) COS(ya)
Az = -COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za) Bz = COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za) Cz = COS(xa) COS(ya) 13
2.3 Pitch Ship by angle dsya
Az' = Az COS(dsya) - Ax SIN(dsya) Ax' = Az SIN(dsya) + Ax COS(dsya) Ay' = Ay
Bz' = Bz COS(dsya) - Bx SIN(dsya) Bx' = Bz SIN(dsya) + Bx SIN(dsya) By' = By
Cz' = Cz COS(dsya) - Cx SIN(dsya) Cx' = Cz SIN(dsya) + Cx COS(dsya) Cy' = Cy
Therefore:
Az' = [-COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za)] COS(dsya) - [COS(ya) COS(za)] SIN(dsya)
Ax' = [-COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za)] SIN(dsya) + [COS(ya) COS(za)] COS(dsya)
Ay' = [SIN(xa) SIN(ya) COS(za)+COS(xa) SIN(za)]
Bz' = [COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za)] COS(dsya) - [-COS(ya) SIN(za)] SIN(dsya)
Bx' = [COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za)] SIN(dsya) + [-COS(ya) SIN(za)] SIN(dsya)
By' = [-SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za)]
Cz' = [COS(xa) COS(ya)] COS(dsya) - [SIN(ya)] SIN(dsya)
Cx' = [COS(xa) COS(ya)] SIN(dsya) + [SIN(ya)] COS(dsya)
Cy' = [-SIN(xa) COS(ya)] 14
2.4 Transform it back to Universe Coordinates:
Ax' = [-COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za)] SIN(dsya) + [COS(ya) COS(za)] COS(dsya)
Bx' = [SIN(xa) SIN(ya) COS(za)+COS(xa) SIN(za)]
Cx' = [-COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za)] COS(dsya) - [COS(ya) COS(za)] SIN(dsya)
Ay' = [COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za)] SIN(dsya) + [-COS(ya) SIN(za)] SIN(dsya)
By' = [-SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za)]
Cy' = [COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za)] COS(dsya) - [-COS(ya) SIN(za)] SIN(dsya)
Az' = [COS(xa) COS(ya)] SIN(dsya) + [SIN(ya)] COS(dsya)
Bz' = [-SIN(xa) COS(ya)]
Cz' = [COS(xa) COS(ya)] COS(dsya) - [SIN(ya)] SIN(dsya) 15
2.5 We are looking for the dza, dya, dxa that give this same result.
Find dya as a function of dsya:
Az = SIN(ya) [From Section 2.1]
Az' = SIN(ya+dya)
= SIN(ya) COS(dya) + COS(ya) SIN(dya) [Trigonometric Expansion]
This must be equal to the Az' obtained by Pitching the Ship.
Az' = [COS(xa) COS(ya)] SIN(dsya) + [SIN(ya)] COS(dsya) [From Section 2.4]
Therefore
SIN(ya) COS(dya) + COS(ya) SIN(dya) = [COS(xa) COS(ya)] SIN(dsya) + [SIN(ya)] COS(dsya)
Assuming dya and dsya are small: COS(dya) = 1, SIN(dya) = dya, COS(dsya) = 1, SIN(dsya) = dsya
SIN(ya) + COS(ya) dya = COS(xa) COS(ya) dsya + SIN(ya)
Cranking through it:
COS(ya) dya = COS(xa) COS(ya) dsya + SIN(ya) - SIN(ya)
= COS(xa) COS(ya) dsya
dya = COS(xa) COS(ya) dsya ------COS(ya)
The result is that: dya = COS(xa) dsya [Equation 7] 16 Find dza as a function of dsya:
Ax = COS(ya) COS(za) [from Section 2.1]
Ax' = COS(ya+dya) COS(za+dza)
= [ COS(ya) COS(dya) - SIN(ya) SIN(dya) ] * [ COS(za) COS(dza) - SIN(za) SIN(dza) ] [Trigonometric expansion]
Assuming dya, dza are small:
Ax' = [ COS(ya) - SIN(ya) (dya) ] [ COS(za) - SIN(za) (dza) ]
= COS(ya) COS(za) - SIN(ya) (dya) COS(za) - SIN(za) (dza) COS(ya) + SIN(ya) (dya) SIN(za) (dza)
Since dya, dza are small the last term {SIN(ya) (dya) SIN(za) (dza)} is approximately zero.
Ax' = COS(ya) COS(za) - SIN(ya) COS(za) dya - SIN(za) COS(ya) dza
This must be equal to the Ax' obtained by Pitching the Ship.
Ax' = [-COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za)] SIN(dsya) + COS(ya) COS(za) COS(dsya) [From Section 2.4]
= -COS(xa) SIN(ya) COS(za) SIN(dsya) + SIN(xa) SIN(za) SIN(dsya) + COS(ya) COS(za) COS(dsya)
Assuming dsya, dsza small:
Ax' = -COS(xa) SIN(ya) COS(za) dsya + SIN(xa) SIN(za) dsya + COS(ya) COS(za)
Therefore:
COS(ya) COS(za) - SIN(ya) COS(za) dya - SIN(za) COS(ya) dza = -COS(xa) SIN(ya) COS(za) dsya + SIN(xa) SIN(za) dsya + COS(ya) COS(za)
Cranking through it:
- SIN(ya) COS(za) dya - SIN(za) COS(ya) dza = -COS(xa) SIN(ya) COS(za) dsya + SIN(xa) SIN(za) dsya 17
From Equation 7, dya = COS(xa) dsya
- SIN(ya) COS(za) COS(xa) dsya - SIN(za) COS(ya) dza = -COS(xa) SIN(ya) COS(za) dsya + SIN(xa) SIN(za) dsya
- SIN(za) COS(ya) dza = -COS(xa) SIN(ya) COS(za) dsya + SIN(xa) SIN(za) dsya + SIN(ya) COS(za) COS(xa) dsya
- SIN(za) COS(ya) dza = -COS(xa) SIN(ya) COS(za) dsya + SIN(xa) SIN(za) dsya + COS(xa) SIN(ya) COS(za) dsya
- SIN(za) COS(ya) dza = SIN(xa) SIN(za) dsya
dza = SIN(xa) SIN(za) dsya ------SIN(za) COS(ya)
The result is that:
dza = - SIN(xa) dsya ------[Equation 8] COS(ya) 18 Find dxa as a function of dsya:
Cz = COS(xa) COS(ya) [from Section 2.1]
Cz' = COS(xa+dxa) COS(ya+dya)
= [ COS(xa) COS(dxa) - SIN(xa) SIN(dxa) ] * [ COS(ya) COS(dya) - SIN(ya) SIN(dya) ] [Trigonometric Expansion]
Assuming dxa, dya are small:
Cz' = [ COS(xa) - SIN(xa) dxa ] [ COS(ya) - SIN(ya) dya ]
= COS(xa) COS(ya) - COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) dya + SIN(xa) dxa SIN(ya) dya
Since dxa, dya are small the last term {SIN(xa) dxa SIN(ya) dya} is approximately zero.
Cz' = COS(xa) COS(ya) - COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) dya
This must be equal to the Cz' obtained by Pitching the Ship.
Cz' = [COS(xa) COS(ya)] COS(dsya) - [SIN(ya)] SIN(dsya) [From Section 2.4]
For small dsya:
Cz' = COS(xa) COS(ya) - SIN(ya) dsya
Therefore:
COS(xa) COS(ya) - COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) dya = COS(xa) COS(ya) - SIN(ya) dsya 19
Cranking through it:
- COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) dya = - SIN(ya) dsya
From Equation 7, dya = COS(xa) dsya , so that:
- COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) COS(xa) dsya = - SIN(ya) dsya
- COS(ya) SIN(xa) dxa = - SIN(ya) dsya + COS(xa) SIN(ya) COS(xa) dsya
= SIN(ya) dsya [ COS(xa) COS(xa) - 1]
dxa = SIN(ya) dsya [ COS(xa) COS(xa) - 1 ] ------COS(ya) SIN(xa)
Since SIN**2 + COS**2 = 1, [ COS(xa) COS(xa) -1 ] = [ -SIN(xa) SIN(xa) ]
dxa = SIN(ya) dsya [ -SIN(xa) SIN(xa) ] ------COS(ya) SIN(xa)
= SIN(ya) dsya [ -SIN(xa) ] ------COS(ya)
The result is that:
dxa = TAN(ya) SIN(xa) dsya [Equation 9] 20 Ship Roll
We want to find out how the Euler angles are changed if we Roll the Ship in its coordinate system.
3.1 Start with Euler equations:
Ax = COS(ya) COS(za) Ay = -COS(ya) SIN(za) Az = SIN(ya)
Bx = SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za) By = -SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za) Bz = -SIN(xa) COS(ya)
Cx = -COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za) Cy = COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za) Cz = COS(xa) COS(ya)
3.2 Transform it to the Ship Frame of Reference
Ax = COS(ya) COS(za) Bx = -COS(ya) SIN(za) Cx = SIN(ya)
Ay = SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za) By = -SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za) Cy = -SIN(xa) COS(ya)
Az = -COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za) Bz = COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za) Cz = COS(xa) COS(ya) 21
3.3 Roll Ship by angle dsxa
Ay' = Ay COS(dsxa) - Az SIN(dsxa) Az' = Ay SIN(dsxa) + Az COS(dsxa)
By' = By COS(dsxa) - Bz SIN(dsxa) Bz' = By SIN(dsxa) + Bz COS(dsxa)
Cy' = Cy COS(dsxa) - Cz SIN(dsxa) Cz' = Cy SIN(dsxa) + Cz COS(dsxa)
Therefore:
Ax' = [COS(ya) COS(za)]
Ay' = [SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za)] COS(dsxa) - [-COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za)] SIN(dsxa)
Az' = [SIN(xa) SIN(ya) COS(za) + COS(xa) SIN(za)] SIN(dsxa) + [-COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za)] COS(dsxa)
Bx' = [-COS(ya) SIN(za)]
By' = [-SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za)] COS(dsxa) - [COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za)] SIN(dsxa)
Bz' = [-SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za)] SIN(dsxa) + [COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za)] COS(dsxa)
Cx' = [SIN(ya)]
Cy' = [-SIN(xa) COS(ya)] COS(dsxa) - [COS(xa) COS(ya)] SIN(dsxa)
Cz' = [-SIN(xa) COS(ya)] SIN(dsxa) + [COS(xa) COS(ya)] COS(dsxa) 22
3.4 Transform it back to Universe Coordinates:
Ax' = [COS(ya) COS(za)]
Bx' = [SIN(xa) SIN(ya) COS(za)+COS(xa) SIN(za)] COS(dsxa) - [-COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za)] SIN(dsxa)
Cx' = [SIN(xa) SIN(ya) COS(za)+COS(xa) SIN(za)] SIN(dsxa) + [-COS(xa) SIN(ya) COS(za) + SIN(xa) SIN(za)] COS(dsxa)
Ay' = [-COS(ya) SIN(za)]
By' = [-SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za)] COS(dsxa) - [COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za)] SIN(dsxa)
Cy' = [-SIN(xa) SIN(ya) SIN(za) + COS(xa) COS(za)] SIN(dsxa) + [COS(xa) SIN(ya) SIN(za) + SIN(xa) COS(za)] COS(dsxa)
Az' = [SIN(ya)]
Bz' = [-SIN(xa) COS(ya)] COS(dsxa) - [COS(xa) COS(ya)] SIN(dsxa)
Cz' = [-SIN(xa) COS(ya)] SIN(dsxa) + [COS(xa) COS(ya)] COS(dsxa)
3.5 We are looking for the dza, dya, dxa that give this same result. 23 Find dya as a function of dsxa:
Az = SIN(ya) [From Section 3.1]
Az' = SIN(ya+dya)
= SIN(ya) COS(dya) + COS(ya) SIN(dya) [Trigonometric Expansion]
This must be equal to the Az' obtained by Rolling the Ship.
Az' = [SIN(ya)] [From Section 3.4]
Therefore:
SIN(ya) COS(dya) + COS(ya) SIN(dya) = [SIN(ya)]
Assuming dya is small:
SIN(ya) + COS(ya) dya = SIN(ya)
COS(ya) dya = SIN(ya) - SIN(ya)
COS(ya) dya = 0
The result is that:
dya = 0 [Equation 10] 24 Find dza as a function of dsxa:
Ax = COS(ya) COS(za) [from Section 3.1]
Ax' = COS(ya+dya) COS(za+dza)
= [ COS(ya) COS(dya) - SIN(ya) SIN(dya) ] * [ COS(za) COS(dza) - SIN(za) SIN(dza) ] [Trigonometric expansion]
Assuming dya, dza are small:
Ax' = [ COS(ya) - SIN(ya) (dya) ] [ COS(za) - SIN(za) (dza) ]
= COS(ya) COS(za) - SIN(ya) (dya) COS(za) - SIN(za) (dza) COS(ya) + SIN(ya) (dya) SIN(za) (dza)
Since dya, dza are small the last term {SIN(ya) (dya) SIN(za) (dza)} is approximately zero.
Ax' = COS(ya) COS(za) - SIN(ya) COS(za) dya - SIN(za) COS(ya) dza
This must be equal to the Ax' obtained by Rolling the Ship.
Ax' = [COS(ya) COS(za)] [From Section 3.4]
Therefore:
COS(ya) COS(za) - SIN(ya) COS(za) dya - SIN(za) COS(ya) dza = COS(ya) COS(za)
Cranking through it:
- SIN(ya) COS(za) dya - SIN(za) COS(ya) dza = 0
From Equation 10, dya = 0
- SIN(za) COS(ya) dza = 0
The result is that:
dza = 0 [Equation 11] 25 Find dxa as a function of dsxa:
Cz = COS(xa) COS(ya) [from Section 3.1]
Cz' = COS(xa+dxa) COS(ya+dya)
= [ COS(xa) COS(dxa) - SIN(xa) SIN(dxa) ] * [ COS(ya) COS(dya) - SIN(ya) SIN(dya) ] [Trigonometric Expansion]
Assuming dxa, dya are small:
Cz' = [ COS(xa) - SIN(xa) dxa ] [ COS(ya) - SIN(ya) dya ]
= COS(xa) COS(ya) - COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) dya + SIN(xa) dxa SIN(ya) dya
Since dxa, dya are small the last term {SIN(xa) dxa SIN(ya) dya} is approximately zero.
Cz' = COS(xa) COS(ya) - COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) dya
This must be equal to the Cz' obtained by Rolling the Ship. From Section 3.4
Cz' = [-SIN(xa) COS(ya)] SIN(dsxa) + [COS(xa) COS(ya)] COS(dsxa)
For small dsxa:
Cz' = -SIN(xa) COS(ya) dsxa + COS(xa) COS(ya)
Therefore:
COS(xa) COS(ya) - COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) dya = -SIN(xa) COS(ya) dsxa + COS(xa) COS(ya)
Cranking through it:
- COS(ya) SIN(xa) dxa - COS(xa) SIN(ya) dya = -SIN(xa) COS(ya) dsxa
From Equation 10, dya = 0
- COS(ya) SIN(xa) dxa = -SIN(xa) COS(ya) dsxa
The result is that: dxa = dsxa [Equation 12] 26 Results
Yaw the Ship by dsza:
dxa = -TAN(ya) COS(xa) dsza [from Equation 6]
dya = SIN(xa) dsza [from Equation 4]
dza = -COS(xa) dsza [from Equation 5] ------COS(ya)
xa' = xa + dxa
ya' = ya + dya
za' = za + dza
Pitch the Ship by dsya:
dxa = TAN(ya) SIN(xa) dsya [from Equation 9]
dya = COS(xa) dsya [from Equation 7]
dza = SIN(xa) dsya [from Equation 8] ------COS(ya)
xa' = xa + dxa
ya' = ya + dya
za' = za + dza 27
Roll the Ship by dsxa:
dxa = dsxa [from Equation 12]
dya = 0 [from Equation 10]
dza = 0 [from Equation 11]
xa' = xa + dxa
ya' = ya + dya
za' = za + dza
The Total comes to:
dxa = -TAN(ya) COS(xa) dsza + TAN(ya) SIN(xa) dsya + dsxa
dya = SIN(xa) dsza + COS(xa) dsya
dza = -COS(xa) dsza + SIN(xa) dsya ------COS(ya)
xa' = xa + dxa
ya' = ya + dya
za' = za + dza
The standard orientation used in aerodynamic modeling has the x axis straight ahead, the y axis to the right, and the z axis straight down.
My model also has the x axis straight ahead and the y axis to the right, but has the z axis straight up. 28
If we replace dsza by -dsza we get:
dxa = TAN(ya) COS(xa) dsza + TAN(ya) SIN(xa) dsya + dsxa
dya = -SIN(xa) dsza + COS(xa) dsya
dza = COS(xa) dsza + SIN(xa) dsya ------COS(ya)
Advantages of Euler angles:
The errors that accumulate are angular errors that are in the player loop and should therefore be unnoticeable.
Disadvantages of Euler angles:
1. One must be able to calculate trigonometric functions for 0 - 360 degrees divided into the smallest incremental angles used.
2. The Euler angles for an object pointed straight up or straight down are indeterminate and therefore are special cases that must be handled.
3. The Tangent function starts getting large above Pitch angles of 60 degrees, requiring floating point arithmetic. Pitch angles in the vicinity of plus or minus 90 degrees may be a problem .
4. The Euler angle functions are only an approximation, valid for small incremental rotations.
Advantages of Unit Vectors:
1. The Trig table is relatively small, consisting only of the number of different incremental angles used.
2. There are no special cases for any orientation.
3. All arithmetic can be done with 16 bit integers. 29
Disadvantages of Unit Vectors:
1. The errors that accumulate result in a distortion of the Universe. [With the use of Magic Angles and Tics this has not been a problem.]
2. Some mathematical models are constructed around the use of Euler angle functions.
Jed Margolin San Jose, CA June 27, 2001
______
Copyright 1986, 2001 Jed Margolin
Send comments through my web site at www.jmargolin.com