rotationMatrixToVector
(Not recommended) Convert 3-D rotation matrix to rotation vector
rotationMatrixToVector
is not recommended. Use the rotmat2vec3d
function instead. For more information, see Version History.
Description
returns an axis-angle rotation vector that corresponds to the input 3-D rotation
matrix. The function uses the Rodrigues formula for the conversion.rotationVector
= rotationMatrixToVector(rotationMatrix
)
Examples
Convert Rotation Matrix to Rotation Vector
Create a matrix representing a 90-degree rotation about the Z -axis.
rotationMatrix = [0 1 0; -1 0 0; 0 0 1];
Find the equivalent rotation vector.
rotationVector = rotationMatrixToVector(rotationMatrix)
rotationVector = 1×3
0 0 1.5708
Input Arguments
rotationMatrix
— Rotation of camera
3-by-3 matrix
Rotation of camera, specified as a 3-by-3 matrix. You can obtain this
matrix by using the estimateExtrinsics
function.
Output Arguments
rotationVector
— Rotation vector
three-element vector
Rotation vector, returned as a three-element vector. The vector represents the axis of rotation in 3-D, where the magnitude corresponds to the rotation angle in radians.
Data Types: single
| double
References
[1] Trucco, Emanuele, and Alessandro Verri. Introductory Techniques for 3-D Computer Vision. Upper Saddle River, NJ: Prentice Hall, 1998.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2016aR2022b: Not recommended
Starting in R2022b, most Computer Vision Toolbox™ functions create and perform geometric transformations using the
premultiply convention. However, the rotationMatrixToVector
function uses the postmultiply convention. Although there are no plans to remove
rotationMatrixToVector
at this time, you can streamline
your geometric transformation workflows by switching to the rotmat2vec3d
function, which supports the premultiply convention.
For more information, see
Migrate Geometric Transformations to Premultiply Convention.
To update your code:
Change instances of the function name
rotationMatrixToVector
torotmat2vec3d
.Specify the rotation matrix as the transpose of the
rotationMatrix
argument of therotationMatrixToVector
function. Alternatively, you can get a rotation matrix in the correct premultiply format by using theestimateExtrinsics
function and querying theR
property of the returnedrigidtform3d
object.
The table shows examples of how to update your code.
Discouraged Usage | Recommended Replacement |
---|---|
This example converts a 3-D rotation matrix in the
postmultiply convention to a rotation vector using the
rotVectorOld = rotationMatrixToVector(rotMatrixOld) | This example converts a 3-D rotation matrix in the
premultiply convention to a rotation vector using the
rotMatrixNew = rotMatrixOld'; rotVectorNew = rotmat2vec2d(rotMatrixNew); |
This example obtains a 3-D rotation matrix in the
postmultiply convention using the
[rotMatrixOld,transVector] = extrinsics( ...
imagePoints,worldPoints,intrinsics);
rotVectorOld = rotationMatrixToVector(rotMatrixOld); | This example obtains a 3-D rotation matrix in the
premultiply convention using the
camExtrinsics = estimateExtrinsics( ...
imagePoints,worldPoints,intrinsics);
rotMatrixNew = camExtrinsics.R;
rotVectorNew = rotmat2vec2d(rotMatrixNew); |
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)