Let's see how rotations work by defining and rotating some 3-D data. You can compute a composition by using matrix multiplication. Note also that some authors change the sign for the R y matrix the sign depends whether you are rotating about the positive or negative Y axis.ģ-D rotation matrices are simple to construct and use in a matrix language #SASTip Click To Tweet Applying rotations to dataĮvery rotation is a composition of rotations in coordinate planes.
This is mathematically equivalent to rotating the object in the opposite direction, so if you prefer a camera-based rotation matrix, use the definitions above but specify the angle -α. NOTE: Some sources define rotation matrices by leaving the object still and rotating a camera (or observer). Start Rot3D (a, axis ) /* rotation in plane perpendicular to axis */ if upcase (axis )= "X" then return RotPlane (a, 2, 3 ) Įlse if upcase (axis )= "Y" then return RotPlane (a, 1, 3 ) Įlse if upcase (axis )= "Z" then return RotPlane (a, 1, 2 ) * Rotate a vector by a counterclockwise angle in a coordinate plane. You specify and axis (X, Y, or Z) to get a rotation matrix in the plane that is perpendicular to the specified axis: The Rot3D function has a simpler calling syntax. It returns the rotation matrix that corresponds to a counterclockwise rotation in the (x i, x j) plane. The RotPlane function takes an angle and a pair of integers.
ROTATION MATRIX HOW TO
This article shows how to implement three-dimensional rotation matrices and use them to rotate a 3-D point cloud. A rotation matrix is especially easy to implement in a matrix language such as the SAS Interactive Matrix Language (SAS/IML). Rotation matrices are used in computer graphics and in statistical analyses.