Rotating cube by quaternions

4 views (last 30 days)
hsgaya
hsgaya on 12 Jul 2019
How can I use quaternions to animate cube in MATLAB R2014a version?
This is the my code to draw cube..
function plot_3d_cube(theta,varargin) %%theta in radian
H=[0 2.5 0 2.5 0 2.5 0 2.5; 0 0 2.5 2.5 0 0 2.5 2.5; 0 0 0 0 2.5 2.5 2.5 2.5]; %Vertices of the cube
S=[1 2 4 3; 1 2 6 5; 1 3 7 5; 3 4 8 7; 2 4 8 6; 5 6 8 7]; %Surfaces of the cube
figure(1)
hold on
H1 = zeros(size(S,1),4)
H2 = zeros(size(S,1),4) ;
H3 = zeros(size(S,1),4) ;
for i=1:size(S,1)
Si=S(i,:);
fill3(H(1,Si),H(2,Si),H(3,Si),'blue','facealpha',0.6)
end
axis equal, axis on, hold off, view(20,10)
I don't know how to use quaternions to animate this(rotate)?
Please anyone can help me?
Thanks

Answers (0)

Categories

Find more on Introduction to Installation and Licensing 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!