I want to plot3 x y z axis and how it moves as rotation matrix.
Show older comments
hi, i want to plot x y z axis at zero position [0 0 0] .
and plot how it changes as rotation matrix for example like [cos(theta) -sin(theta) 0; sin(theta) cos(theta) 0; 0 0 1]
but i when i rotate the dot [0 0 0], the x y z axis does not moves together.
please help me!!
1 Comment
Angelo Yeo
on 11 Aug 2023
안녕하세요. 문의하신 내용을 정확하게 파악하지 못하였습니다. 한국어로 작성하시는게 편하시다면 댓글에 한국어로 문의사항을 좀 더 자세하게 작성해 보시겠어요? 다른 한국 사람들이 보고 더 적절한 도움을 드릴 수도 있습니다.
Accepted Answer
More Answers (1)
George Abrahams
on 14 Dec 2023
Hi 동후, you can plot the axes (basis vectors) of the rotation matrix with my plotframe function on File Exchange. When you change the rotation matrix, you can update its position with the UpdateFrame name-value argument, so that it animates. For example:
f = figure;
ax = axes( f, 'DataAspectRatio', [1 1 1], 'View', [37.5 30], ...
'XLim', [-.5 1.1], 'YLim', [-.5 1.1], 'ZLim', [-.5 1.1], ...
'XGrid', 'on', 'YGrid', 'on', 'ZGrid', 'on' );
% Initialise the plot before beginning the animation.
hg = plotframe( Parent=ax );
rotation = 0;
while isgraphics( f )
% Calculate the new rotation matrix.
transformationMatrix = makehgtform( 'axisrotate',[1 1 1], rotation );
rotationMatrix = transformationMatrix(1:3,1:3);
% Update the plot.
plotframe( rotationMatrix, UpdateFrame=hg )
% drawnow is required to force MATLAB to render the updated figure on each loop.
drawnow
rotation = rem( rotation + 0.04, 2 * pi );
end
Categories
Find more on Graphics Object Properties 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!