the same rotation matrix. For example, suppose we use the convention above; then we have the following equivalent pairs: {| style="text-align:right" | (90°,||45°,||−105°) || ≡ || (−270°,||−315°,||255°) || multiples of 360° |- | (72°,||0°,||0°) || ≡ || (40°,||0°,||32°) || singular alignment |- | (45°,||60°,||−30°) || ≡ || (−135°,||−60°,||150°) || bistable flip |} Angles for any order can be found using a concise common routine (; ). The problem of singular alignment, the mathematical analog of physical gimbal lock, occurs when the middle rotation aligns the axes of the first and last rotations. It afflicts every axis order at either even or odd multiples of 90°. These singularities are not characteristic of the rotation matrix as such, and only occur with the usage of Euler angles. The singularities are avoided when considering and manipulating the rotation matrix as orthonormal row vectors (in 3D applications often named the right-vector, up-vector and out-vector) instead of as angles. The singularities are also avoided when working with quaternions. Vector to vector formulation In some instances it is interesting to describe a rotation by specifying how a vector is mapped into another through the shortest path (smallest angle). In this completely describes the associated rotation matrix. In general, given , the matrix belongs to and maps to . Uniform random rotation matrices We sometimes need to generate a uniformly distributed random rotation matrix. It seems intuitively clear in two dimensions that this means the rotation angle is uniformly distributed between 0 and 2. That intuition is correct, but does not carry over to higher dimensions. For example, if we decompose rotation matrices in axis–angle form, the angle should not be uniformly distributed; the probability that (the magnitude of) the angle is at most should be , for . Since is a connected and locally compact Lie group, we have a simple standard criterion for uniformity, namely that the distribution be unchanged when composed with any arbitrary rotation (a Lie group "translation"). This definition corresponds to what is called Haar measure. show how to use the Cayley transform to generate and test matrices according to this criterion. We can also generate a uniform distribution in any dimension using the subgroup algorithm of . This recursively exploits the nested dimensions group structure of , as follows. Generate a uniform angle and construct a rotation matrix. To step from to , generate a vector uniformly distributed on the -sphere