Rotation Matrix in estimateMo​noCameraPa​rameter.m

6 次查看(过去 30 天)
Hi, I need to find the distance of a vehicle from ego-vehicle using monocular camera. I can accomplish it using Visual Perception Using Monocular Matlab given. But I need to know the math behind it, on of them is the rotation matrix to align camera coordinate with vehicle coordinate in estimaMonoCameraParameter.m, In there I found
% R = [cos(a)*cos(c)-sin(a)*cos(b)*sin(c), -cos(a)*sin(c)-sin(a)*cos(b)*cos(c), sin(a)*sin(b);
% sin(a)*cos(c)+cos(a)*cos(b)*sin(c), -sin(a)*sin(c)+cos(a)*cos(b)*cos(c), -cos(a)*sin(b);
% sin(b)*sin(c), sin(b)*cos(c), cos(b)]
to be the rotation matrix. But I can decompose the rotation matrix to elementary matrix to find the order of rotation. Please help me. Thank you so much.

回答(1 个)

Ashok
Ashok 2025-2-13,3:18
The example on Matrix Rotations and Transformations illustrates how rotation matrices can be used to rotate a vector with respect to a frame. The example can be accessed through the following link.
From the example, Rx, Ry, and Rz represent the rotation matrices to rotate a vector by an angle t about the x, y, and z axis respectively.
Rx = [1 0 0; 0 cos(t) -sin(t); 0 sin(t) cos(t)];
Ry = [cos(t) 0 sin(t); 0 1 0; -sin(t) 0 cos(t)];
Rz = [cos(t) -sin(t) 0; sin(t) cos(t) 0; 0 0 1];
By experimenting with different combinations and orders of these matrices, the order and sense of each rotation can be determined. This process can be simplified using symbolic variables. Here’s a snippet that creates a rotation matrix as described:
syms a b c
% Rotation matrices for rotating vector about the frame
Rz1 = [cos(a) -sin(a) 0; sin(a) cos(a) 0; 0 0 1];
Rx = [1 0 0; 0 cos(b) -sin(b); 0 sin(b) cos(b)];
Rz2 = [cos(c) -sin(c) 0; sin(c) cos(c) 0; 0 0 1];
R = Rz1*Rx*Rz2
R = 
This implies that the rotation order is as follows:
  1. Rotate the vector about z axis by an angle a
  2. Rotate the vector about the new x axis by an angle b
  3. Rotate the vector about the new z axis by an angle c
Starting from MATLAB R2022b, the rigidtform3d function is available to store an overall transformation matrix with three rotations and three translations. More information about this function can be found here:

Community Treasure Hunt

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

Start Hunting!

Translated by