Flip and rotate matrix
Show older comments
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]
2 Comments
Bjorn Gustavsson
on 10 Nov 2020
Yes, that looks right. As Walter illustrated what I suggested, the operations do not commute, as long as you remember which order they are done you'll be fine. (memory is of crucial importance here, in my experience, if this is something you'll do over and over again wrap it into a function that you write a very clear help-section for. Before I did that the rotation-function was something I had to redo on a semi-yearly basis...).
Diego Hens
on 10 Nov 2020
Edited: Diego Hens
on 10 Nov 2020
Accepted Answer
More Answers (1)
Bjorn Gustavsson
on 10 Nov 2020
0 votes
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
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!