Is it possible, To get a Forward, Right and Up Directional Vectors just from Euler Angles, no quaternions or Matrices. I don't mind if it is slower, how fast the code is isn't my main goal. I've been wrapping my head about quaternions and Matrices for 2 weeks, and it didn't work, when I came here I got a response that didn't event work or gave any useful information. I know there is a huge ton of questions like this But I searched over all possible sites and the answer was always to use Quaternions or Matrices, so is it even possible ?
1 Answers
In 3D To transform vector without matrices You just rewrite the matrix*vector
operation
(x',y',z') = M*(x,y,z)
into:
x' = m[0][0]*x + m[0][1]*y + m[0][2]*z;
y' = m[1][0]*x + m[1][1]*y + m[1][2]*z;
z' = m[2][0]*x + m[2][1]*y + m[2][2]*z;
where the matrix m[row][col]
is (just 3x3 rotational part) result of 3 axis aligned rotation matrices:
multiplied together in order you use (algebraicaly as equations you can do this in any math SW like Derive for Windows if you too lazy like me) for example:
Both images where taken from wiki so for example
m[0][0]=(cos(a)*cos(b))
m[0][1]=((cos(a)*sin(b)*sin(c))-(sin(a)*cos(c)))
m[0][2]=((cos(a)*sin(b)*cos(c))-(sin(a)*sin(c)))
x' = m[0][0]*x + m[0][1]*y + m[0][2]*z;
-----------------------------------------------------
x' = (cos(a)*cos(b))*x + ((cos(a)*sin(b)*sin(c))-(sin(a)*cos(c)))*y + ((cos(a)*sin(b)*cos(c))-(sin(a)*sin(c)))*z
I am too lazy to write the rest (that is one of the reason why matrices are used its more convenient). Also for the sake of speed precompute the sin
and cos
values of a,b,c
angles into variables like cosa,cosb,cosc,sina,sinb,sinc
and use that instead of calling the same slow goniometric functions again and again so...
x' = (cosa*cosb)*x + ((cosa*sinb*sinc)-(sina*cosc))*y + ((cosa*sinb*cosc)-(sina*sinc))*z
Now you just use this to transform 3 unit directions (1,0,0),(0,1,0),(0,0,1)
and the result will be your vectors.
for more info about the topic see:

- 49,595
- 11
- 110
- 380