简体   繁体   中英

Bumpy and wrinkled Spheres in Matlab

I'm trying to surface bumpy spheres and wrinkled spheres in Matlab using p = 1 + 0,2 * sin(phi * m) * sin(teta * n)

    teta = 0:6.23;
    phi = 0:3.14;
    [teta,phi] = meshgrid(teta, phi);
    figure, hold on
    for m = 1:12
        for n = 1:12
            p = 1 + 0.2*sin(m*teta).*sin(n*phi);
            surf(teta,phi,p)
            pause(0.05)
            clf('reset')
        end
    end

But it's not drawing any sphere just surfaces...what am I doing wrong and what should I change :) Thanks a lot!!!

I don't understand your example so I created a new one:

%We define the spherical coordinates.
theta   = linspace(0,2*pi,50);
phi     = linspace(0,pi,50);
[x1,x2] = meshgrid(linspace(0,12*pi,50),linspace(0,12*pi,50)); %the variation of rho will produce a bumpy sphere.
rho     = 0.1*(sin(x1)+cos(x2))+1;
[theta,phi] = meshgrid(theta,phi);

%we calculate the cartesian coordinates.
x   =   rho.*cos(theta).*sin(phi);
y   =   rho.*sin(theta).*sin(phi);
z   =   rho.*cos(phi);

%plot   
surf(x,y,z);

RESULT BUMPY

在此处输入图片说明

RESULT WRINKLED

Simply change the rho parameter by:

rho     = 0.1*(sin(x1))+1;

在此处输入图片说明

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