RandomRotationMatri​x

Generate a random 3 x 3 rotation matrix in SO(3).
14 Downloads
Updated 12 Aug 2023

View License

Note that each column of a 3 x 3 rotation matrix can be thought of as the x, y and z-axis of some reference frame placed with some orientation.
Using this fact, we do the following:
  1. We set the x-axis to be a random 3D unit vector.
  2. Then, we generate the y-axis by finding a unit vector that is perpendicular to the x-axis. This is done by generating another random 3D vector and then computing the cross product with the x-axis.
  3. Finally, the z-axis must be the cross product of the x-axis and the y-axis.
Puting these three axis in one matrix side by side, we get a 3 x 3 rotation matrix.

Cite As

Seong Hun Lee (2024). RandomRotationMatrix (https://www.mathworks.com/matlabcentral/fileexchange/132613-randomrotationmatrix), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2023a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.2

Fixed the way a random 3D unit vector is generated.

1.0.1

Updated the description.

1.0.0