rotate3d_to_AA() converts from (post-multiplied) rotation matrix
to an axis-angle representation of 3D rotations.
Arguments
- mat
3D rotation matrix (post-multiplied). If you have a pre-multiplied rotation matrix simply transpose it with
t()to get a post-multiplied rotation matrix.- unit
A string of the desired angular unit. Supports the following strings (note we ignore any punctuation and space characters as well as any trailing
s's e.g. "half turns" will be treated as equivalent to "halfturn"):"deg" or "degree"
"half-revolution", "half-turn", or "pi-radian"
"gon", "grad", "grade", or "gradian"
"rad" or "radian"
"rev", "revolution", "tr", or "turn"
See also
https://en.wikipedia.org/wiki/Axis-angle_representation for more details
about the Axis-angle representation of 3D rotations.
rotate3d() can be used to convert from an axis-angle representation to a rotation matrix.
Examples
# axis-angle representation of 90 degree rotation about the x-axis
rotate3d_to_AA(rotate3d("x-axis", 90, unit = "degrees"))
#> $axis
#> <Coord3D[1]>
#> x y z w
#> 1 0 0 1
#>
#> $theta
#> <angle<degrees>[1]>
#> [1] 90°
#>
# find Axis-Angle representation of first rotating about x-axis 180 degrees
# and then rotating about z-axis 45 degrees
R <- rotate3d("x-axis", 180, unit = "degrees") %*%
rotate3d("z-axis", 45, unit = "degrees")
AA <- rotate3d_to_AA(R)
# Can use `rotate3d()` to convert back to rotation matrix representation
all.equal(R, do.call(rotate3d, AA))
#> [1] TRUE
