[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Rotation matrix definition
From: |
kingcrimson |
Subject: |
Re: Rotation matrix definition |
Date: |
Fri, 22 Nov 2019 12:35:35 +0100 |
> Il giorno 21 nov 2019, alle ore 14:55, Farzad Torabi <address@hidden> ha
> scritto:
>
> loading the nurbs package , it seemed to be working.
>
> ok, let's make the example, the vector X of the new CS is : [-115.830
> -16.850 113.400] in the global CS
>
> I myself used the
>
> anglex = atan2(norm(cross(a,b)), dot(a,b))
>
> to check the angle between Xglobal and Xnew and it should be 44.7° ( also
> checked with CAD)
>
> so my next steps could have been finding the angles with all other axes and
> then form the transformation matrix and multiply it in the old Vecotr
>
> but
> instead, using the proposed formula :
>
> T = vecrot(pi, (vecXnew + [1; 0; 0])/2)
>
> I get
>
> T =
>
> -0.66887 0.33401 0.33401 0.00000
> 0.33401 -0.66308 0.33692 0.00000
> 0.33401 0.33692 -0.66308 0.00000
> 0.00000 0.00000 0.00000 1.00000
>
> is it the same result ? meaning : the total transformation matrix ?
mmmh... I was assuming your vector would be a COLUMN but instead you have a ROW.
This creates an issue which is connected to broadcasting (see [1] to understand
what broadcasting is
and how it works).
In short (vecnorm (vecXnew) + [1; 0; 0])/2 is supposed to give the average
between vecXnew
normalized and the x-axis but, if vecXnew is a row you get a matrix instead of
a vector:
> (vecXnew + [1; 0; 0])/2
ans =
-57.4150 -7.9250 57.2000
-57.9150 -8.4250 56.7000
-57.9150 -8.4250 56.7000
to get the correct answer you have to make sure your vector is a COLUMN
> (vecXnew(:) + [1; 0; 0])/2
ans =
-57.4150
-8.4250
56.7000
so the correct syntax is in your case :
T = vecrot(pi, (vecnorm (vecXnew(:)) + [1; 0; 0])/2)
and you can check that it does the expected transformation
by verifying that
> norm (T * [1;0;0;1] - [vecnorm(vecXnew(:)); 1] , inf)
ans = 1.2490e-16
so, if you apply T to the x-axis direction you do get
your vector direction.
Notice that I am using 4x1 vectors and 4x4 matrices
as this works with homogeneous coordinates [2]
The standard 3x3 rotation matrix is the upper left block of T:
> norm (T(1:3,1:3) * vecnorm(vecXnew(:)) - [1; 0; 0], inf)
ans = 1.1102e-16
c.
[1] https://octave.org/doc/interpreter/Broadcasting.html#Broadcasting
[2] https://en.wikipedia.org/wiki/Homogeneous_coordinates
- Re: Rotation matrix definition, (continued)
- Re: Rotation matrix definition, Farzad Torabi, 2019/11/21
- Re: Rotation matrix definition, Carlo De Falco, 2019/11/21
- Re: Rotation matrix definition, Carlo de Falco, 2019/11/21
- Re: Rotation matrix definition, kingcrimson, 2019/11/21
- Re: Rotation matrix definition, Farzad Torabi, 2019/11/21
- Re: Rotation matrix definition, kingcrimson, 2019/11/21
- Re: Rotation matrix definition, Farzad Torabi, 2019/11/21
- Re: Rotation matrix definition, Nicholas Jankowski, 2019/11/21
- Re: Rotation matrix definition, Farzad Torabi, 2019/11/21
- Re: Rotation matrix definition, Farzad Torabi, 2019/11/21
- Re: Rotation matrix definition,
kingcrimson <=
- Re: Rotation matrix definition, Farzad Torabi, 2019/11/25
- Re: Rotation matrix definition, Farzad Torabi, 2019/11/25
- Re: Rotation matrix definition, Farzad Torabi, 2019/11/26
- Re: Rotation matrix definition, kingcrimson, 2019/11/26
- Re: Rotation matrix definition, Farzad Torabi, 2019/11/26
- Re: Rotation matrix definition, Carlo de Falco, 2019/11/27
- Re: Rotation matrix definition, Carlo de Falco, 2019/11/27
Re: Rotation matrix definition, Francesco Potortì, 2019/11/21