Rotate 1 by N vector
Show older comments
Hello, everyone. Is there a way (function) in Matlab to rotate a row vector of N dimensions by a given angle? I've only been able to use the matrix multiplication for 2D and 3D cases.
Thanks!
5 Comments
Jan
on 8 Mar 2018
To define a rotation you need the angle and the axis to rotate around. How is the axis of rotation defined in your case?
Peter Popoola
on 9 Mar 2018
Guillaume
on 9 Mar 2018
If you are talking about rotations in N-dimensional space (N>3), then a search with your favourite engine would reveal that:
a) it's far from trivial
b) there's plenty of papers written about it, involving maths that are way beyond me. Clifford algebra is mentioned a lot.
Peter Popoola
on 10 Mar 2018
Jan
on 10 Mar 2018
I consider this as not complicated:
R = eye(numel(u)) + ...
(v * u.' - u * v.') * sin(a) + ...
(u * u.' + v * v.') * (cos(a) - 1);
Here u and v are two orthogonal unit vectors to describe the n-dimensional hyperplane to rotate in. Remember, that in 3D one vector is sufficient to define a plane to rotate in, but in 4D (and N-D), this is not unique anymore. a is the angle in radians to rotate, and the direction is from u to v.
I publish this in the FileExchange currently.
Answers (2)
Rik
on 8 Mar 2018
You mean something like this?
v=1:10;
v2=imrotate(v,45);
5 Comments
Peter Popoola
on 9 Mar 2018
Rik
on 9 Mar 2018
I don't get an error, so what is the exact code you're using?
Peter Popoola
on 10 Mar 2018
Peter Popoola
on 10 Mar 2018
Here the axis of rotation u, the cross-product matrix []_x and the tensor cross-product (x) are not limited to 3D, but work for n dimensions also. So you can create the n-D rotation matrix in a straight-forward way and multiply your vector with.
Categories
Find more on Gravitation, Cosmology & Astrophysics 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!