Convert rotation matrix into representation used in VRML
Takes an input of a rotation matrix and outputs the axis/angle rotation representation used for defining rotations in VRML. The rotation matrix can be either a 9-element column vector or a 3-by-3 matrix defined columnwise.
Maximum value to treat input value as zero — The input is considered to be zero if it is equal to or lower than this value.
A representation of a three-dimensional spherical rotation as a 3-by-3 real, orthogonal matrix R: RTR = RRT = I, where I is the 3-by-3 identity and RT is the transpose of R.
In general, R requires three independent angles to specify the rotation fully. There are many ways to represent the three independent angles. Here are two:
You can form three independent rotation matrices R1, R2, R3, each representing a single independent rotation. Then compose the full rotation matrix R with respect to fixed coordinate axes as a product of these three: R = R3*R2*R1. The three angles are Euler angles.
You can represent R in terms of an axis-angle rotation n = (nx,ny,nz) and θ with n*n = 1. The three independent angles are θ and the two needed to orient n. Form the antisymmetric matrix:
Then Rodrigues' formula simplifies R: