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

조회 수: 8 (최근 30일)
GURPREET
GURPREET 2012년 8월 1일
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

답변 (1개)

Sumit Tandon
Sumit Tandon 2012년 8월 1일
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.

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by