Getting a new rotation matrix from an existing one by rotating an angle about a certain axis

2 次查看(过去 30 天)
I have a large set of rotation matrices from which I am trying to generate another set of rotation matrices by rotating the existing ones about certain axes by angles 1-180 degrees. So rotation matrix A would be [a11, a12, a13; a21, a22, a23; a31, a32, a33], and the B rotation matrices would be obtained by rotating A about the, say, [1 1 1] axis by angles of 1-180 degrees. Is there a way to do this that already exists? I haven't been able to find it.

回答(1 个)

Aparajith Raghuvir
Aparajith Raghuvir 2021-6-21
It is my understanding that you are looking for a function that can rotate an object about an axis by a specific angle.
The rotate function should serve your needs. You can input a rotation matrix, an axis, and an angle alpha to rotate by.
rotate(h, direction, alpha)
where h is the object to be rotated.
  2 个评论
Michael Costa
Michael Costa 2021-6-21
Thanks for your answer. When I try to use the rotate function, it is giving me the error
Error using rotate
Too many output arguments.
Error in test (line 4)
b = rotate(rotma, [1 1 1], 60);
When I try to run the code
rotma = [1 1 1; 2 1 1; -2 4 2];
b = rotate(rotma, [1 1 1], 60);
Aparajith Raghuvir
Aparajith Raghuvir 2021-6-22
"Too many output arguments." error comes up because the rotate function doesn't have an output you can assign.
Further it was built for graphics objects, so you would need to cast rotma as an image and run it as follows:
rotate(image(rotma), [1 1 1], 60);
This will result in a figure being plotted and opened. However, since there is no ouput, fetching the values of the modified matrix needs a workaround which I have suggested below:
  • Run the following command
edit rotate
  • This will open up the code for the rotate function.
  • Use the code to understand how the rotated values are computed.
  • You will notice that 'newxyz' variable contains the rotated matrix which you can use.
  • You can create your own function with the same code which returns 'newxyz' as output which you can use further in your workflow.
I hope this helps.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 3-D Scene Control 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by