It returns an unsigned unite quaternion in
rot2quat(X)
A unsigned unite quaternion.
A rotation matrix in SO(3).
Anamul Sajib.
R implementation and documentation: Anamul Sajib <sajibstat@du.ac.bd>.
Firstly construct a system of linear equations by equating the corresponding components of the theoretical rotation matrix proposed by Prentice (1986), and given a rotation matrix. Finally, the system of linear equations are solved by following the tricks mentioned in second reference here in order to achieve numerical accuracy to get quaternion values.
Prentice,M. J. (1986). Orientation statistics without parametric assumptions.Journal of the Royal Statistical Society. Series B: Methodological 48(2). //http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
quat2rot, rotation, Arotation \ link{rot.matrix}
x <- rnorm(4)
x <- x/sqrt( sum(x^2) ) ## an unit quaternion in R4 ##
R <- quat2rot(x)
R
x
rot2quat(R) ## sign is not exact as you can see
Run the code above in your browser using DataLab