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

- 122 questions asked
- 14 answers
- 2 accepted answers
- reputation: 8

- 145 questions asked
- 6.005 answers
- 2.625 accepted answers
- reputation: 14.464

Accepted Answer by Matt J

- 145 questions asked
- 6.005 answers
- 2.625 accepted answers
- reputation: 14.464

5 views (last 30 days)

5 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 )

- 145 questions asked
- 6.005 answers
- 2.625 accepted answers
- reputation: 14.464

Answer by Matt J
on 14 Jun 2019

- 145 questions asked
- 6.005 answers
- 2.625 accepted answers
- reputation: 14.464

Accepted Answer

You could use this FEX file

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 ?

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

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 ?

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

Thank you !

is the following correct ?

rotm= regParams.R;

eulZYX = rotm2eul(rotm);

It is correct if that is the decomposition that you want.

the three angles with principle axes ?

The three angles of what with the principal axes?

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);

Thank you so much! What is the ~ sign?

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.

what is the shortcut key for that sign and what is it called ?

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 ?

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

just one doubt :

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

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

It won't matter because point1(:) is always a column vector.

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

What is eulZYX?

>> which eulZYX

'eulZYX' not found.

@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.

ok thank you

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

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

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 ?

And why should the method change ? was the previous one not valid ?

apparently the second method is not right, why is it different ?

@Mat J

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

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

rotm= regParams.R;

eulZYX = rotm2eul(rotm);

@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

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.

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)

@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

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

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 ?

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.

Sign in to comment.

- 72 questions asked
- 12.347 answers
- 4.332 accepted answers
- reputation: 30.025

Answer by Jan
on 27 Jun 2019

- 72 questions asked
- 12.347 answers
- 4.332 accepted answers
- reputation: 30.025

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

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 ?

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.

Thank you very much Jan

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply TodayUnable 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

## farzad (view profile)

## Direct link to this comment

https://nl.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.