Transformation matrix between two cartesian systems
79 views (last 30 days)
Show older comments
Maciej Kupras on 31 Oct 2022
Commented: Maciej Kupras on 1 Nov 2022
I do have some points in 3D inertial frame of reference, that are randomly generated, but are meant to be measured with a sensor on a box. Let's say their coordinates are:
I also do have a vector that the sensor 'is looking' into the direction of. These is a unit vector made from randomly generated direction:
sensor_angles=[ro;theta;fi]; %this is the angle that sensor is looking at
sensor_direction=sensor_angles./norm(sensor_angles);%this is a unit vector that a sensor is looking at
I would like to have my inertial coordinates to have transformed into the reference frame of a sensor, but in a way that my new y_sesnor axis would be around zero (as the sensor is positioned on the Y axis of the box). I tried making transformation matrix:
C_F1_1=[cos(ro) -sin(ro) 0;sin(ro) cos(ro) 0;0 0 1];
C_F1_2=[cos(theta) 0 sin(theta);0 1 0; -sin(theta) 0 cos(theta)];
C_F1_3=[1 0 0 ;0 cos(fi) -sin(fi);0 sin(fi) cos(fi)];
C_F1=C_F1_1*C_F1_2*C_F1_3; %final transformation matrix
And then the multiplying. And as I understand, the A matrix should me coordinates in a referance frame of a sensor.
However, the new matrix is nowhere near the zero at Y (and any) axis.
For an example, for the 10 randomly generated points I get the matrix of randomly generated points on a sphere with a radius=1:
Columns 1 through 9
0.3246 -0.6403 0.5266 -0.0176 0.4037 -0.0428 0.7374 0.7950 -0.6923
0.8497 -0.5035 -0.8488 0.0264 0.8840 0.5389 0.2422 -0.5109 0.3030
0.4154 0.5801 -0.0476 -0.9995 -0.2358 0.8413 0.6306 0.3271 -0.6549
-0.1894 -0.0823 0.9784
0.7331 -0.6748 0.0852
0.6533 0.7334 0.1881
The final A matrix:
Columns 1 through 9
0.2750 0.7303 -0.0765 -0.9768 -0.3799 0.7869 0.4574 0.2115 -0.5345
-0.3001 -0.0802 0.9548 -0.1158 -0.3207 -0.3235 0.4308 0.9554 -0.7678
0.9134 -0.6784 -0.2874 -0.1802 0.8677 0.5255 0.7780 0.2062 -0.3533
Then, I check which points from the A matrix are "visible" (follow up to my previous question: https://www.mathworks.com/matlabcentral/answers/1839323-angle-between-two-3d-vectors) for the sensor (that has POV of a circle of 10 degrees to the each side). It turns out that the sensor sees:
And as you can see, A_fov is nowewhere near close the sensor_direction:
How can I solve the problem?
Jim Riggs on 31 Oct 2022
Edited: Jim Riggs on 31 Oct 2022
Coordinate rotation (or transformation) involves expressing the coordinates of a point defined in one reference frame in terms of another frame. Coordinate frame rotations may be conducted in one of two “directions”. The conventions used to describe the rotation directions are “direct” and “inverse”. These conventions are linked to the definition of the rotation displacement angle(s).
Consider the Z-axis rotation depicted in the figure. The figure illustrates two sets of axes, one in blue (with axes X, Y, and Z) and one in red (with axes X’, Y’, and Z’). From the perspective of the figure, the red frame is displaced relative to the blue frame. This is implied by the sense of the angle psi . The figure indicates that the angle psi is measured from the blue to the red, and is a positive rotation about the Z axis using the right-hand rule. By definition, the coordinates of a vector in the displaced (red) frame may be transformed to the fixed (blue) frame using the direct transformation. The opposite transform is the inverse transformation. The inverse transformation will transform the coordinates of a point in the fixed (blue) frame to the displaced (red) frame. Note that the fixed (blue) frame is considered as our point of reference, or frame of observation, and it is the fixed frame which is used to define the sign of the angle, psi. Now, suppose that we take a point of observation in the red frame. With our point of observation in the red frame, we treat the red frame as the fixed frame, and observe that the blue frame has been displaced from the red frame through angle -psi. The displacement angle, psi, is now defined relative to the Z’ (red) axis, is a negative rotation in the figure. From this perspective, if we wish to transform the coordinates of a point from the blue frame to the red frame, this would now be a direct transformation (a transformation from the displaced frame to the fixed frame is a direct transformation), and the value for psi, as defined in the red frame, is now a negative rotation angle.
- When describing the relationship between two reference frames, one must be used as the fixed reference (frame of observation) to describe the displacement of the other. The choice may be arbitrary, but the fixed reference defines the sign convention for the angle rotations.
- The direct transformation transforms the coordinate of a point from the displaced frame to the fixed frame.
- The inverse transformation transforms the coordinates of a point from the fixed frame to the displaced frame.
- The direct transformation through angle psi, is equivalent to the inverse transformation through angle -psi, and vice versa.
More Answers (0)
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!