Applying rotation matrix on inclined plane

11 views (last 30 days)
mat
mat on 4 Apr 2016
Edited: mat on 13 Apr 2016
Hey, I want to rotate an inclined plane to a flat surface. I think I can use the Euler angles to perform this operation.
Using following points:
X=repmat([-2:2],5,1)
Y=repmat([-2:2]',1,5)
A=4:-1:0;
Z=[A;A-1;A-2;A-3;A-4]
and following rotation matrix
I think you can make the plane flat by following rotations: 1: rotation around x-axis by 45° 2: rotation around y-axis by -45° 3: no rotation around z-axis
updating the rotation matrix:
new Z matrix derived from 3rd row:
newZ=-X*cosd(45)*sind(-45))+Y*sind(45)+Z*cosd(45)*cosd(-45);
I expect a zero matrix, but this is not the case? What am I doing wrong?
Thank you

Accepted Answer

sam0037
sam0037 on 12 Apr 2016
Hi,
My understanding is that you would like to rotate this given plane (which passes through origin) such that the normal of the plane is parallel to z-axis. And this is what you mean by flattening the plane.
1. I don't understand why the sequence of rotation mentioned in the question would result into flattening of this plane.
2. The final orientation of the plane will depend on the sequence and the angle of rotations with which the plane is rotated about the axes.
3. First we need to find the normal of the original plane. This can be easily done by taking the cross product of any three linearly independent points on the plane. Here the unit normal (un) is 1/root(3)*[1 1 1]. You can also take negative of this normal.
4. After the rotation of the plane our desired unit normal (vn) should be [0 0 1]. You can also take negative of this normal.
5. The axis of rotation about which we rotate this plane is the cross product of un and vn. And the angle of rotation is the cosine inverse of the inner dot product of un and vn.
6. With the help of this compute the rotation matrix using the MATLAB function ' vrrotvec2mat ' or compute it using the equations described here .
7. Finally use this rotation matrix to get the desired result.
8. To get the Eulerian angles use the function 'rotm2eul' or again compute it using other resources from Google like this .
9. The Eulerian angles are -15 degree about Z axis, -35.2644 degree about Y axis and 45 degree about X axis. The sequence of rotation is ZYX. You can use these angles to verify this at your end.
Please refer to the code below for illustration purpose. Please note this requires access to the following functions: a. vrrotvec2mat - requires Simulink 3D Animation Toolbox b. rotm2eul - requires Robotics System Toolbox
%%declare the points
X=repmat([-2:2],5,1);
Y=repmat([-2:2]',1,5);
A=4:-1:0;
Z=[A;A-1;A-2;A-3;A-4];
f=figure;
ax=gca;
hold on;
surf(X,Y,Z)
p = @(x) [X(x),Y(x),Z(x)];
rotX = @(x) [1 0 0; 0 cosd(x) -sind(x); 0 sind(x) cosd(x)];
rotY = @(x) [cosd(x) 0 sind(x);0 1 0; -sind(x) 0 cosd(x)];
rotZ = @(x) [cosd(x) -sind(x) 0; sind(x) cosd(x) 0; 0 0 1];
u = cross(p(3)-p(11),p(3)-p(16));
un = u'/norm(u,2);
vn = [0;0;1];
rot = vrrotvec2mat([cross(un,vn); acos(un'*vn)]);
newX_t = X*rot(1,1)+Y*rot(1,2)+Z*rot(1,3);
newY_t = X*rot(2,1)+Y*rot(2,2)+Z*rot(2,3);
newZ_t = X*rot(3,1)+Y*rot(3,2)+Z*rot(3,3);
surf(newX_t,newY_t,newZ_t)
disp(newZ_t)
eul = rotm2eul(rot,'ZYX')*180/pi;
rot_t = rotZ(eul(1))*rotY(eul(2))*rotX(eul(3));
disp(eul)
  1 Comment
mat
mat on 12 Apr 2016
Edited: mat on 13 Apr 2016
Thank god, this helped me a lot, thank you.
I'm wondering if I can calculate the Euler angles directly? What I found out (by drawing http://ggbtu.be/m3133887): slope along both x-axis and y-axis is 45°
The relation I found out with ROTy for example: atand(tand(45)*cosd(45)) is 35.2644°
How can I find these formulas?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!