*LocalAxesDef(EulerAngles)
This is similar to the LocalAxesDef command, only with the EulerAngles option.
It returns three numbers that are the 3 Euler angles (radians) that define a local axes system , with the so-called "
x-convention," (see https://mathworld.wolfram.com/EulerAngles.html)
How to calculate X[3] Y[3] Z[3] orthonormal vector axes from three euler angles angles[3]
cosA= cos (angles[0]) sinA= sin (angles[0]) cosB= cos (angles[1]) sinB= sin (angles[1]) cosC= cos (angles[2]) sinC= sin (angles[2]) X[0]= cosC*cosA - sinC*cosB*sinA X[1]= -sinC*cosA - cosC*cosB*sinA X[2]= sinB*sinA Y[0]= cosC*sinA + sinC*cosB*cosA Y[1]= -sinC*sinA + cosC*cosB*cosA Y[2]= -sinB*cosA Z[0]= sinC*sinB Z[1]= cosC*sinB Z[2]= cosB |
How to calculate euler angles angles[3] from X[3] Y[3] Z[3] orthonormal vector axes
if (Z[2]<1.0-EPSILON && Z[2]>-1.0+EPSILON){ double senb= sqrt (1.0-Z[2]*Z[2]); |
angles[ |
0]= acos ( |
angles[2]=
acos
(Z[1-Y[2]/senb); if ( |
X[ |
2]/senb<0.0) angles[ |
0]=M_2PI-angles[0]; angles[1]= acos (Z[2]); angles[ |
2]= acos ( |
Z[ |
1]/senb); if ( |
Z[ |
0]/senb<0.0) angles[ |
2]=M_2PI-angles[ |
2]; |
} else { angles[0]=0.0; angles[1]= acos (Z[2]) |
angles[0]=0.0; angles[2]= acos (X[0]); if (-X[1]<0.0) angles[2]=M_2PI-angles[2]; |
} |