Transformation matrix between two cartesian systems
Afficher commentaires plus anciens
Hi,
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:
B=[x_inertial;y_inertial;z_inertial]
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:
ro=2*pi*rand;
theta=2*pi*rand;
fi=2*pi*rand;
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.
A=C_F1*B;
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:
B =
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
Column 10
0.1225
-0.0318
-0.9920
Sensor angles:
sensor_angles =
1.8237 %ro
5.5713 %theta
1.3197 %fi
Transformation matrix:
C_F1 =
-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
Column 10
-0.9912
0.0268
-0.1299
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:
A_fov =
0.2115
0.9554
0.2062
And as you can see, A_fov is nowewhere near close the sensor_direction:
sensor_direction =
0.3035
0.9272
0.2196
How can I solve the problem?
11 commentaires
Jim Riggs
le 31 Oct 2022
This is the kind of problem that will answer itself if you simply draw a good diagram defining all of the reference frames and angles.
Maciej Kupras
le 31 Oct 2022
It's hard for me to comment without understanding how your axes and angles are defined.
It looks like you have the right approach using the three planar rotations, but I need to see how the axes and angles are defined in order to check your rotations.
Can you provide a drawing with all these details?
Maciej Kupras
le 1 Nov 2022
Modifié(e) : Maciej Kupras
le 1 Nov 2022
Based on your drawing, the two reference frames should be co-aligned when all rotation angles are zero (this is convenient). Assuming that the sign convention for your angles is defnined by the right-hand rule using the inertial reference frame, then to transform points from the inertil frame to the sensor frame, you need to use the inverse form of the planar rotations (see my discussion in my answer - you are transforming points from the fixed frame to the displaced frame).
Also, your equation for the sensor unit vector does not seem right to me. If you want the line of sight vector for the star sensor, this is simply the Y-axis of the sensor frame, so the sensor unit vector would be:
sensor_direction = C_F1 * [0, 1 0] % C_F1 defined as the INVERSE transformation
Maciej Kupras
le 1 Nov 2022
Maciej Kupras
le 1 Nov 2022
Jim Riggs
le 1 Nov 2022
If B is an array of points in the inertial frame and C_F1 is the direction cosine matrix based on the inverse rotation direction, then A is the same array of points expressed in the sensor frame.
I don't understand what you mean by "on the Y axis"
Maciej Kupras
le 1 Nov 2022
Jim Riggs
le 1 Nov 2022
The plane perpendicular to the Y axis is the X-Z plane. Any point with a -Y value will be behind the camera, and any point with a +Y value is in front of the camera. The camera probably has a limited field of view, so you would need to calculate the angle from the camera boresight to each point to tell whether it is visible to the camera.
for each point P[x; y; z], the angle off boresight (i.e. the Y-axis) is
acos(dot([0,1,0], P./norm(P)) % angle from the Y-axis, (radians)
Maciej Kupras
le 1 Nov 2022
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Axes Transformations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



