10 views (last 30 days)

Hello,

this is a mathematical question, probably very easy for some people, but I want to make sure my solution is correct.

I have a matrix of points P with three columns (for x, y and z coordinates) and tons of rows, let's say one thousand ,but the number really doesn't matter.

I have to flip this matrix P and rotate it with given flipping (let's call it F) and rotation (let's call it R) matrices. A flip of the x-coordinates wo be a matrix as in [-1 0 0; 0 1 0; 0 0 1], for example. The roation matrix is also a 3x3 matrix, but not so simple as that (but it's given).

I would like to unite these two matrices in one for future calculations and I'm not sure if the multiplication of the two would be correct, as in:

flip_and_rotate = R * F %R is for the Rotation and F for the flipping

I'm aware that when rotating the order of rotations is important. It's not the same to rotate first in x and then in y as the other way around. Does this matter here?

Thank you.

Edit:

I'll add an example:

P = [ 1 1 0] % This is my point, just one instead of 1000

F = [-1 0 0; 0 1 0; 0 0 1]

T = [0.9999,-0.0097,-0.001;0.0095,0.9998,-0.0160;0.0101,0.01593,0.9998]

First comes the flipping, then the rotation:

Flipping = F * transpose(P)

Rotation = ]The result is [-1.009600000000000;0.990300000000000;0.005830000000000]

Walter Roberson
on 10 Nov 2020

format short g

F = [-1 0 0; 0 1 0; 0 0 1]

R4 = makehgtform('zrotate', -pi/4); %counter-clockwise 45 degrees

R3 = R4(1:3,1:3);

P = [1, 1, 1]; %[X Y Z]

P*R3 % / ends up ^

P*F %flip, / ends up \

P*F*R3 %flip then rotate, / becomes \ then rotates to <-

P*R3*F %rotate then flip, / rotates to ^ then flips to v

Bjorn Gustavsson
on 10 Nov 2020

Ehrm, not that much od a flip of in the latter case when the x-component goes from 1e-16 to -1e-16?

Bruno Luong
on 10 Nov 2020

Don't know since I don't read the question entirely. Simply answer

"It is then not possible to get the same result as in P*F*R3 with just one matrix?"

Note that all rotation matrix has determinant 1, flip has determinant -1. So one cannot represent a flip by a rotation. The group SO(3) is not O(3). R3 is in SO(3), F is not. Bothe are in O(3).

Bjorn Gustavsson
on 10 Nov 2020

In my experience, it is best to test whether the flipping and rotation operations commute with a small enough example - do it with pen (or pencil) and paper. Take for example a point [1 1 0] and rotate it around [0 0 1] by pi/3 before and after flipping the x-component.

That test will give you the answer.

HTH

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

Start Hunting!
## 2 Comments

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/643065-flip-and-rotate-matrix#comment_1122980

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/643065-flip-and-rotate-matrix#comment_1122980

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/643065-flip-and-rotate-matrix#comment_1123020

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/643065-flip-and-rotate-matrix#comment_1123020

Sign in to comment.