简体   繁体   中英

How to create a 3D object that keeps rotating?

I have used isosurface function as follows:

isosurface(data);
grid on; axis equal;
colormap copper;
alpha(0.1);
hold on; 

How do I make the object rotate on its own?

I'm thinking about two possible solutions:

First, you could redraw the surface a number of times, each time incrementing by a small angle the position. Something like:

for i=1:length_of_animation
    [theta,phi,r] = cart2sph(x,y,z);
    [x,y,z] = sph2cart(theta+small_angle, phi, r);
    delete(h);
    h = isosurface(x,y,z)
end

Second, you could move the camera around the plot using the campos function. see mathworks details . This will not make the surface rotate, but will make the view point rotate. Playing with the camera could be a little tricky tho.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM