Transformation matrix between two cartesian systems

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

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.
I tried that, and this is the solution I came up with. I was thinking that maybe I need another rotation so the axis would be aligned, however - but shouldn't the rotation matrix I use rotate the B matrix to the new coordinates system so that it would align (in some way) with the sensor vector (from whome I get the rotation angles)?
Jim Riggs
Jim Riggs le 31 Oct 2022
Modifié(e) : Jim Riggs 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
Maciej Kupras le 1 Nov 2022
Modifié(e) : Maciej Kupras le 1 Nov 2022
Yes, sure. So I'm going to be more specific. And my angles are defined from the main axes of the inertial frame, it does not matter (I think?) in which direction they go.
Inertial cartesian frame of reference (ECI coordinate system):
And the sensors frame of refence (on a satellite). Currently, I'm just trying to do the star sensor. And as the star sensor sees the stars in the narrow FOV, I suspect, that those stars in the sensor reference frame should be close to the Y axis.
Jim Riggs
Jim Riggs le 1 Nov 2022
Modifié(e) : Jim Riggs 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
Ok, I fully understand the need inverse rotation - it's right, I have forgotten about it from previous classes.
And as of the second thing, you might be right - I am going to check this today. Thank you very very much :P
Ok, it seems to be working, but confirm one thing please: the new matrix A=C_F1*B is the matrix of coordinates of the points in the reference frame of the sensor on the Y axis, right?
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"
Sorry if that was unclear. This is not my favourite knowledge domain so I don't know how to explain some things.
As the sensor is looking in the direction of the Y axis, the points from A matrix are in the coordinate system of the sensor located on the wall that is perpendicular to that axis.
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)
Right, I understand. Thank you very much for the huge help.

Connectez-vous pour commenter.

 Réponse acceptée

Jim Riggs
Jim Riggs le 31 Oct 2022
Modifié(e) : Jim Riggs le 31 Oct 2022

2 votes

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.
To summarize,
  • 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.

Plus de réponses (0)

Produits

Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by