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 件のコメント

Jan
Jan 2018 年 3 月 8 日
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
Peter Popoola 2018 年 3 月 9 日
Thanks, Jan. The axis of rotation in this case I'm not too sure of, but I figure it should be around the first co-ordinate, that is, the x-axis. I don't think it's too important what the axis of rotation is in this algorithm (Imperialist Competitive Algorithm, in case you are interested). We just need to be able to perform a rotation of all variables (dimensions) along one axis. Apologies for the late reply!
Guillaume
Guillaume 2018 年 3 月 9 日
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
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 日

1 投票

You mean something like this?
v=1:10;
v2=imrotate(v,45);

5 件のコメント

Peter Popoola
Peter Popoola 2018 年 3 月 9 日
Thanks, Rik. However, upon executing this code, I get the following error:
error: Y(2): out of bound 1
error: called from
interp2 at line 238 column 10
imremap>grayinterp at line 82 column 12
imremap at line 67 column 19
imperspectivewarp at line 124 column 17
imrotate at line 158 column 20
Rik
Rik 2018 年 3 月 9 日
I don't get an error, so what is the exact code you're using?
Peter Popoola
Peter Popoola 2018 年 3 月 10 日
I'm using exactly the code which you presented here. On the Octave shell.
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 日

1 投票

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!
Jan
Jan 2018 年 3 月 10 日

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeGravitation, Cosmology & Astrophysics についてさらに検索

質問済み:

2018 年 3 月 8 日

コメント済み:

Jan
2018 年 3 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by