How to animate this object and rotate from initial to final?

8 views (last 30 days)
Hi I have this object that looks like a flower and i want to rotate from its initial position to its final position. I have the code. the objects from initial to 30 degrees to 45 degrees and stops at 60 degrees. I want to make it like a movie
The Code
original
x = -2.5:.1:2.5;
y = -2.5:.1:2.5;
[X,Y] = meshgrid(x,y);
Z = 2*sin(X.*Y);
surf(X,Y,Z)
Final
title('flower')
yr = (sqrt (3)+1)/2
xr = (3 * sqrt (2) - sqrt(6))/4
zr = (sqrt(6) + sqrt(2))/4
xs = (6+2*sqrt(3)+3*sqrt(2)+sqrt(6))/8
ys = (2+ 2*sqrt(3) +3*sqrt(2)-3*sqrt(6))/8
zs = (sqrt(6) + sqrt(2))/4
X = -2.5:.1:2.5;
y = -2.5:.1:2.5;
[X,Y] = meshgrid(x,y);
Z = 2*sin(X.*Y);
H1 = surf(X,Y,Z)
zdir = [1 1.3660 .3660];
rotate(H1,zdir,30)
zdir = [yr xr zr];
rotate(H1,zdir,45)
zdir = [ys xs zs];
rotate(H1,zdir,60)
grid on
hold on

Answers (1)

Sumit Tandon
Sumit Tandon on 1 Aug 2012
You can use a combination of the functions CAMORBIT, GETFRAME and MOVIE to rotate and object, capture a snapshot of the figure as a movie frame and then play it back as a movie.

Categories

Find more on Animation in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!