ROTATION3DAXISANDANGLE Determine axis and angle of a 3D rotation matrix.
[AXIS, ANGLE] = rotation3dAxisAndAngle(MAT)
Where MAT is a 4-by-4 matrix representing a rotation, computes the
rotation axis (containing the points that remain invariant under the
rotation), and the rotation angle around that axis.
AXIS has the format [DX DY DZ], constrained to unity, and ANGLE is the
rotation angle in radians.
Note: this method use eigen vector extraction. It would be more precise
to use quaternions, see:
http://www.mathworks.cn/matlabcentral/newsreader/view_thread/160945
Example
origin = [1 2 3];
direction = [4 5 6];
line = [origin direction];
angle = pi/3;
rot = createRotation3dLineAngle(line, angle);
[axis angle2] = rotation3dAxisAndAngle(rot);
angle2
angle2 =
1.0472
See also
transforms3d, vectors3d, angles3d, eulerAnglesToRotation3d
Package: matgeom