rotate vectors onto each other and Euler angles

37 Ansichten (letzte 30 Tage)
Istvan
Istvan am 26 Jun. 2018
Kommentiert: Istvan am 27 Jun. 2018
I would like to find out how to rotate a vector in 3D from one orientation to another with a series of rotations (around x, around y, around z -- or any other order) so it ends up forming pre-defined angles with the coord. system axes.
Details:
Let us consider a fixed coordinate system xyz: see attached image Image of the system. In this coordinate system, there is vector U (unit length), forming angle a with the x axis, angle b with the y axis and angle c with the z axis. a,b,c are known. Let us rotate the same vector (now called U1) to form angles a1, b1, c1 with the same axes x, y and z. a1, b1, c1 are known. Correct me if I am wrong, but I think a,b,c are not Euler angles ( Euler angles )-- right?
Usually the rotation matrix (R, rotating U to U1 from starting orientation to final orientation as defined above) is composed by a series of 3 rotations around the axes x, y and z by angles alpha, beta, gamma (respectively). The order can vary. This is clear on Wikipedia ( Rotation matrix ).
Question:
What are the angles alpha, beta, gamma that make up the rotation matrix (how can they be expressed in function of a, b, c, a1, b1, c1 vector to axes angles), in case of (i) x-y-z and (ii) z-y-x rotation orders? Correct me if I am wrong, but I think alpha, beta, gamma will be Euler angels -- in contrast to a, b, c.
Matlab code examples would be appreciated, just as tips regarding eul2rotm() function's angle definitions(drawing?).
Thank you!

Akzeptierte Antwort

Jan
Jan am 26 Jun. 2018
Bearbeitet: Jan am 26 Jun. 2018
Let's assume we talk about the 3D case.
A rotation matrix is an ortho-normal 3x3 matrix. R.' * R is the unity matrix, or in other words: rotating in one direction at first and then backwards in the opposite direction does not change the data.
A general rotation in 3D is specified by a unit vector (called u here) to rotate around and the angle of rotation (called alpha). Then we get this general rotation matrix (see FEX: RotationMatrix):
s = sin(alpha);
c = cos(alpha);
% 3D rotation matrix:
x = u(1);
y = u(2);
z = u(3);
mc = 1 - c;
R = [c + x * x * mc, x * y * mc - z * s, x * z * mc + y * s; ...
x * y * mc + z * s, c + y * y * mc, y * z * mc - x * s; ...
x * z * mc - y * s, y * z * mc + x * s, c + z * z .* mc];
There are different conventions depending on the point of view: Do you rotate the coordinate system or the object. So maybe R.' is matching in your case.
This is called "direction cosine matrix" also, because it contains the projections of a vector into the coordinate system. You can interpret this matrix as rotated coordinate system also and its 3 vectors (rows or columns) build an orthonormal tripod.
While this is the general matrix, which performs the operation of rotating around a vector, there are a number of different methods, to split this matrix into 3 different rotations around axes fixed to the coordinate system or to the body. The Euler angles or Euler-Cardan (also called Tait–Bryan) angles: The matrix R is split into 3 matrices of the style:
R1 = [ c1, -s1, 0;
s1, c1, 0;
0, 0, 1];
R2 = [ c2, 0, s2;
0, 1, 0;
-s2, 0, c2];
R3 = [ 1, 0, 0;
0, c3, -s3;
0, s3, c3];
Here "s1" means: sin(alpha1) etc.
Now you can decide for a certain convention, e.g. R3*R2*R1, or R3*R2*R3 (yes, the index can be repeated), etc. The angles alpha1, alpha2, alpha3 are called the Euler angles. Their definition requires a decision for a specific order. Different fields of science use typical conventions for order, e.g. analysis of human motion and aerospace engineering.
In your case neither a,b,c nor a1,b1,c1 are Euler angles. See https://en.wikipedia.org/wiki/Euler_angles for details.
if you have the two vectors a and b and want to get the rotation matrix needed to transform one into the other, you can follow these steps:
  • The axis of rotation is the normalized cross-product:
u = cross(a, b) / norm(cross(a, b))
  • The rotational angle is defined by:
alpha = atan2(norm(cross(a, b)), dot(a, b))
  • Use the above formula to create R.
An equivalent solution:
na = a / norm(a);
nb = b / norm(b);
v = cross(na, nb);
skew = [0, -v(3), v(2); v(3), 0, -v(1); -v(2), v(1), 0];
R = eye(3) + skew + skew ^ 2 * (1 - dot(na, nb)) / (norm(v))^2;
  4 Kommentare
Jan
Jan am 26 Jun. 2018
I picked this up from my lessons in classical mechanics and maths. We used the standard literature: Bronstein, Scheck: Classical Mechanics, Boas, ... A nice web resource is kwon3d (link) or of course WikiPedia.
Remember that there is no unique rotation matrix between two vectors. The two shown methods create different R also. Example:
a = [1, 0, 1] / sqrt(2)
b = [1, 0, -1] / sqrt(2)
You can obtain b from a by rotating around the x axis by 180 degree, or around the y axis by 90 degree. There is an infinite number of other rotations. To define a rotation uniquely, you need 3 vectors, which define a 3D body.
Istvan
Istvan am 27 Jun. 2018
Ok, I see. And in case of 3 vectors we have the original problem of going forward and back between 2 arbitrary coordinate systems (one being the base and the other assigned / fixed to the 3D body). That makes sense.
Thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by