MATLAB Answers

- You will see updates in your activity feed.
- You may receive emails, depending on your notification preferences.

3 views (last 30 days)

Hi All

How do I define the transformation matrix of a plate that moves in space , knowing the old and new coordinates of 3 points on the plate ? (assume a circular plate and reference coordinate system in the center of the plate )

Matt J
on 14 Jun 2019

You could use this FEX file

farzad
on 17 Jun 2019

Thank you very much

just a question about calling the function, should I nest this in my code, or I can call the function when it is in a separate file ?

and in the second case , how do I do that ?

Matt J
on 17 Jun 2019

You can call absor like any Matlab command. You can also obtain usage instructions using help or doc like in any Matlab command

>> doc absor

farzad
on 17 Jun 2019

Thank you , that was written also in the code.

and one thing : I needed to have the angles with the axes of reference system.

for 2D problems it gives

regParams.theta

is there something equivalent for 3D I could get from this code ?

Matt J
on 17 Jun 2019

Attached are some functions for decomposing a 3x3 rotation matrix into angles in various ways.

farzad
on 27 Jun 2019

Thank you !

is the following correct ?

rotm= regParams.R;

eulZYX = rotm2eul(rotm);

farzad
on 27 Jun 2019

Matt J
on 27 Jun 2019

That would be,

angles=acosd(regParams.R*InitialNormal)

where InitialNormal is the initial normal to the plate as a 3x1 vector:

P=[point1(:),point2(:),point3(:)].';

[~,~,V]=svd(P-mean(P));

InitialNormal=V(:,end);

Matt J
on 27 Jun 2019

You are welcome, but please accept-click the answer if it was what you were looking for.

The ~ tells Matlab that an ouput argument will not be used and that it need not assign it to any output variable.

farzad
on 28 Jun 2019

and another doubt :

if the initial vector is like [0,0,1] , then is the regParams.R gives the angles in the same order ?

XYZ ?

farzad
on 28 Jun 2019

also one thing , how do i force the angle results be smaller than 90° starting from 0 ° ?

Matt J
on 28 Jun 2019

farzad
on 1 Jul 2019

just one doubt :

should the point1 be a one row or one column matrix ?

P=[point1(:),point2(:),point3(:)].';

farzad
on 1 Jul 2019

Thank you , still sorry for the question : is the result of eulZYX in Radians or degrees ?

Jan
on 2 Jul 2019

@farzad: Do not assume, that the users of the forum have installed the same 3rd party tools or Matlab toolboxes as you have. Check the location of the functions by which . If it is not included in the standard toolboxes, post a link to the documentation or source of the function.

By the way: A simple test reveals, what the output is.

farzad
on 20 Sep 2019

Ok . I tried for this triangle, and it does not work !!

A1= [10 -70 0; 60 30 0; -40 50 0]

A2= [10 -61.812 -22.498; 60 26.491 9.642; -40 44.151 16.07]

these are the coordinates of a triangle that has rotated around the X axis for 20° , with no rotation around the other axes. the triangle is in XY plane by the way.

so when I use absor, I get :

>> Alfa= eulZYX(1)

Alfa =

-0.0371

>> Beta= eulZYX(2)

Beta =

-0.0198

>> gamma=eulZYX(3)

gamma =

-0.0345

Matt J
on 20 Sep 2019

Here's what I get:

>> reg=absor(A1.',A2.','doTrans',0);

>> rot2taitbryan(reg.R,'xyz')

ans =

20.0003 0.0001 0.2375

>> acosd(reg.R(:,3))

ans =

89.9999

110.0003

20.0003

farzad
on 20 Sep 2019

Thank you so much!!! but I had no idea if I had to use the functions this way, were these in absor documents ?

but it does not work for me !! I don't have rot2taitbryan function, what is it ?

farzad
on 20 Sep 2019

@Mat J

shall you please explain me kindly , why did you use this new way ? and why the previous suggestion was not working ?

Matt J
on 20 Sep 2019

farzad
on 20 Sep 2019

ok, then what is the difference of this decomposition with the above ?

rotm= regParams.R;

eulZYX = rotm2eul(rotm);

Matt J
on 20 Sep 2019

farzad
on 20 Oct 2019

@Matt J Hi Mat. reading Wikipedia, I still have doubt about the roll angle.

cause what I need as Roll , is the rotation around the original X axis, Yaw , the rotation around the original Z axis, and pitch: the rotaion around the original Y axis

all of the Euler methods give the rotation around a new axis at some point

Matt J
on 20 Oct 2019

cause what I need as Roll , is the rotation around the original X axis, Yaw , the rotation around the original Z axis, and pitch: the rotaion around the original Y axis

That is what rot2taitbryan gives you.

farzad
on 20 Oct 2019

Thank you, exactly the script you wrote in the comments above? Intrinsic and extrinsic confuse me

There are six possibilities of choosing the rotation axes for Tait–Bryan angles. The six possible sequences are:

x-y′-z″ (intrinsic rotations) or z-y-x (extrinsic rotations) y-z′-x″ (intrinsic rotations) or x-z-y (extrinsic rotations) z-x'-y″ (intrinsic rotations) or y-x-z (extrinsic rotations) x-z′-y″ (intrinsic rotations) or y-z-x (extrinsic rotations) z-y′-x″ (intrinsic rotations) or x-y-z (extrinsic rotations): the intrinsic rotations are known as: yaw, pitch and roll y-x′-z″ (intrinsic rotations) or z-x-y (extrinsic rotations)

farzad
on 20 Oct 2019

@Mat J how does this code recognize what was the order of the rotations applied?

Cause the stste of a plane is different if you apply Rx first then Ry, then Rz With the case that you first apply Rz, then Rx and then Ry

Matt J
on 21 Oct 2019

As mentioned in the help doc, the code only does extrinsic rotations and the order of the rotations is specified by the second input argument:

>> help rot2taitbryan

Calculates extrinsic Tait-Bryan angles from rotation matrix

ang = rot2taitbryan(R,order)

* `R`: Rotation matrix (3x3)

* `order`: Order of angles to return; any of:

{'XYZ','XZY','YXZ','YZX','ZYX','ZXY'} %case insensitive

* `ANG`: Angles (degrees) in specified order

NOTE: order of application of these rotations is right-to-left, both as

indicated by `order` and `ANG'. So, as an example,

>> R=Rz(30)*Ry(20)*Rx(60)

R =

0.8138 0.0065 0.5811

0.4698 0.5811 -0.6645

-0.3420 0.8138 0.4698

>> rot2taitbryan(R,'zyx')

ans =

30.0000 20.0000 60.0000

farzad
on 5 Nov 2019

Dear Matt : thank you for the above answer : but what if I don't know the order of rotation ?? this command asks for the order actually

second question : Does Absor.m give me the rotation matrix ? how can I get it ?

Matt J
on 5 Nov 2019

but what if I don't know the order of rotation

The order is something you choose not something you determine. All 6 decompositions are equivalent - it just depends on your preference.

Does Absor.m give me the rotation matrix

Yes, it is in the regParams.R output.

Jan
on 27 Jun 2019

You can define the motion by a translation of the center of the 3 points and a rotation of the local coordinate system.

PointsA = [x1, y1, z1; ...

x2, y2, z2; ...

x3, y3, z3];

PointsB = ...

Translation = mean(PointsB, 1) - mean(PointsA, 1);

% For the local coordinate systems find an orthonormal tripod:

v1 = PointsA(1, :) - PointsA(2, :);

n1 = v1 ./ norm(v1);

v2 = PointsA(2, :) - PointsA(3, :);

n2 = v2 ./ norm(v2);

c2 = cross(n1, n2);

n12 = c2 ./ norm(c2);

CoorA = [n1, n12, cross(n1, n12)];

% The same for B...

Rotation = CoorA * CoorB'

Anotehr approach would be the "Helical Axis": Any motion can be defined by an axis and some rotation around it and translation along it. See http://www.kwon3d.com/theory/jkinem/helical.html

farzad
on 27 Jun 2019

thank you

my main question is the rotations. I was using something similar to your suggestion, but it was giving not satisfying results.

so you are saying that using absor and rcParams.R is not a good idea ?

Matt J
on 27 Jun 2019

so you are saying that using absor and rcParams.R is not a good idea ?

Jan's approach will be sub-optimal if you have non-neglible measurement errors in A and B. Also, if you decide to use more than 3 points (for data redundancy), absor will better accommodate that case.

Jan
on 28 Jun 2019

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

Start Hunting!Opportunities for recent engineering grads.

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

Start Hunting!Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web siteYou can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

- América Latina (Español)
- Canada (English)
- United States (English)

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)

## 1 Comment

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/467055-how-to-find-the-transformation-matrix-for-a-plat-knowing-the-old-and-new-coordinates-of-3-points-on#comment_714778

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/467055-how-to-find-the-transformation-matrix-for-a-plat-knowing-the-old-and-new-coordinates-of-3-points-on#comment_714778

Sign in to comment.