Rotate 1 by N vector

2 次查看(过去 30 天)
Peter Popoola
Peter Popoola 2018-3-8
评论: Jan 2018-3-10
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 个评论
Peter Popoola
Peter Popoola 2018-3-10
Thanks for the comment, Guillaume. I didn't know that. I guess I'll have to find a way around it.
Jan
Jan 2018-3-10
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.

请先登录,再进行评论。

回答(2 个)

Rik
Rik 2018-3-8
You mean something like this?
v=1:10;
v2=imrotate(v,45);
  5 个评论
Rik
Rik 2018-3-10
File a bug report with GNU. There are often minor differences between Octave and Matlab, especially in edge cases like this. Apparently Octave assumes both dimensions are larger than 1.
Peter Popoola
Peter Popoola 2018-3-10
Okay, Rik. Thank you!

请先登录,再进行评论。


Jan
Jan 2018-3-8
编辑:Jan 2018-3-10
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.
  2 个评论
Peter Popoola
Peter Popoola 2018-3-9
Thanks once again, Jan. I take it there's no Matlab function that does this? Because I haven't really been able to wrap my head around the formulation given here, and how it can be extended to the N-dimensional case. Thank you for your help!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Gravitation, Cosmology & Astrophysics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by