This section is divided into a number of subsections, links to which are:
Euler Theorem
A twodimensional xy coordinate frame can be considered to be a part of the threedimensional coordinate frame by adding a zaxis perpendicular to the x and yaxes. However, there are two orientations for this line: one in which the positive direction of the axis is out of the paper and another where the positive direction of the axis is into the paper. It doesn’t matter which one we choose as long as the choice is consistent.
Consistency is made more difficult when the sciences do not agree. Elsewhere we have made a point about how physicists and mathematicians do not agree on a naming convention for axes in the complex plane. Similarly, and confusingly, geometers and topologists cannot agree on a convention for numbering coordinates in space underlying equations. A useful article covering this may be found in the Hypersphere section of Wolfram MathWorld at this link. The message here is that you must adapt your consistency to the context and conform to parochial rules laid down by those who passed before you.
The conventional choice is the right hand rule. Curl the ﬁngers of your right hand so that they go by the shortest path from the one axis to another axis. Your thumb now points in the positive direction of the third axis. For the familiar x and yaxes on paper, curl your ﬁngers on the short 90◦ path from the xaxis to the yaxis (not on the long 270◦ path from the xaxis to the yaxis). When you do so your thumb points out of the paper and this is taken as the positive direction of the zaxis.
The following diagram shows the righthand coordinate system. Note that the arrow is a semicircle that begins and ends touching the y plane. The arrow direction is the same as the curl of your fingers.
Leonhard Euler proved the following theorem in 1775 that states that in threedimensional space, any displacement of a rigid body such that a point on the rigid body remains fixed, is equivalent to a single rotation about some axis that runs through the fixed point.
 TaitBryan variant of Euler Angles. In the TaitBryan convention, each of the three angles in a Euler angle triplet defines the rotation around a different Cartesian axis. For example, the first angle may specify the rotation around the z axis, the second around the y axis, and the third around the x axis. For classic Euler angles, the three elemental rotations are performed around only two axes. For example, the first rotation may be around the z axis, the second around the y, and the third around the z axis again. Both systems are capable of representing all possible 3D rotations, and there is no inherent advantage of one over the other. However, most modern authors use the TaitBryan convention, and that is what we will use here. [Note: purists will claim that TaitBryan angles are not true Euler angles, but that view contravenes common usage.]
 Intrinsic rotation (the axes move with each rotation). In an intrinsic system, each of the elemental rotations is performed on the coordinate system as rotated by the previous operation(s). In an extrinsic system, each rotation is performed around the axes of the world coordinate system, which does not move. As an example, suppose the three angles of the Euler triplet specify rotations around the z, y, and x axes respectively, and in that order. The first elemental rotation around the z axis will be identical for both intrinsic and extrinsic conventions. However, for the intrinsic convention the second elemental rotation is performed around the y axis in its new position resulting from the first rotation, while in the extrinsic convention it is performed around the original (unrotated) y axis. Similarly, the final rotation around the x axis will be performed around the x axis as rotated by the first two operations in the intrinsic system, and around the original (unrotated) x axis in the extrinsic system. This paper will adhere to the intrinsic convention: i.e., the axes move with each rotation.
 Active (otherwise known as alibi) rotation when the point is rotated, not the coordinate system.
 Passive rotation—also known as alias rotation—is when the coordinate system rotates with respect to the point . The two conventions produce opposite rotations.

Righthanded coordinate system with righthanded rotations.
We will use a righthanded Cartesian coordinate system with righthanded rotations. In a righthanded coordinate system, if x̂, ŷ, and ẑ̂ are unit vectors along each of the three axis, then x̂ cross ŷ = ẑ. Righthanded rotation means rotations are positive clockwise when looking in the positive direction of any of the three axes.
Yawpitchroll rotation order, rotating around the z, y and x axes respectively
The order in which the rotations are performed is signiﬁcant. The primary problem with Euler angles is that they contain singularities at 0 or 90 degrees that lead to gimbal lock. When this occurs, 2 axes are parallel and it is not possible to rotate independently about a third “locked” axis. For example, if using Euler angles to describe an airplane that is rotated upward 90 degrees about it’s pitch axis so that it is pointing straight up, the yaw and roll axes become the same, and one degree of freedom is lost or “locked”. In this case, it’s not possible to independently describe tilt towards the left or right wings.
https://www.sagemotion.com/blog/howdoeulerangleswork https://danceswithcode.net/engineeringnotes/rotations_in_3d/rotations_in_3d_part1.html
If the application of Euler angles doesn’t involve angles at or near the singularities, then this problem goes away (e.g. commercial airplanes don’t fly vertically. Euler angles can also be computed by converting from 3D rotation matrix:
There are three axes so there should be 3³ = 27 sequences of Euler angles. However, there is no point in rotating around the same axis twice in succession because the same result can be obtained by rotating once by the sum of the angles, so there are only 3 · 2 · 2 = 12 different Euler angle sequences:
xyx  xyz  xzx  xzy  
yxy  yxz  yzx  yzy  
zxy  zxz  zyx  zyz 
EulerRodrigues' rotation formula
If v is a vector in ℝ³ and n is a unit vector describing an axis of rotation about which v rotates by an angle θ according to the right hand rule, the EulerRodrigues formula for the rotated vector v_{rot} is
The rotation matrix can be expressed through the crossproduct matrix:
The matrix for an arbitrary rotation
Example 1 alowed rotations of a vector around the axes zyx by 90° each. The matrix for arbitrary rotations around these axes is obtained by multiplying the matrices for each axis using arbitrary angles: a rotation of ψ around the zaxis, a rotation of θ around the yaxis and a rotation of φ around the xaxis. The resulting matrix is computed as follows. First multiply the rotation around the xaxis by the rotation around the yaxis:Gimbal Lock
https://www.gathering4gardner.org/g4g13gift/math/BickfordNeilGiftExchangeWhyDoTheUnitQuaternionsDoubleCoverTheSpaceOfRotationsG4G13.pdfWhen, for instance, the pitch angle θ = +90° or −90°, both of these conditions, cos(θ) = 0, and we can see that r_{1,1}, r_{2,1}, r_{3,2}, and r_{3,3} must all equal zero. Since the arctan function is not defined at (0,0), equations for Euler's angles are not valid when the pitch angle θ = ±90°.
It is worth noting that in the regions near the two gimbal lock points, the mapping from rotationspace to Euler angles is not continuous, meaning very small changes in orientation can result in discontinuous jumps in the corresponding Euler angles. For example, the Euler angles (0°,89°,0°) and (90°, 89°, 90°) represent orientations that are only about a degree apart, despite their very different numerical values. A good analogy is the way an aircraft’s longitude jumps discontinuously as it flies over the North or South Pole. This behavior causes problem when trying to interpolate between orientations, or find the average of multiple orientations (see below).
 Anderson, R.U., Elementary geometric proof of Euler's rotation theorem, 2019.
 BenAri, M., A Tutorial on Euler Angles and Quaternions, Weizmann Institute of Science.
 Cheng, Hui; Gupta, K. C. (March 1989). An Historical Note on Finite Rotations. Journal of Applied Mechanics. 56 (1). American Society of Mechanical Engineers: 139–145. Retrieved 20220411.
 Dunn, F. and Parberry, I. (2002). 3D math primer for graphics and game development. Plano, Tex.: Wordware Pub.
 Foley, James D.; van Dam, Andries; Feiner, Steven K.; Hughes, John F. (1991), Computer Graphics: Principles and Practice (2nd ed.), Reading: AddisonWesley, ISBN 0201121107
 Palais, B., Palais, R., and Rodi, S., A Disorienting Look at Euler’s Theorem on the Axis of a Rotation, MAA,
 Matrices and Linear Transformations
 Rogers, D.F., Adams, J. A., Mathematical Elements for Computer Graphics, McGrawHill Science/Engineering/Math, 1989.
 Watt, A., 3D Computer Graphics, AddisonWesley; 3rd edition, 1999.