Can someone help me with these 3D plots?

조회 수: 1 (최근 30일)
Victor
Victor 2013년 12월 16일
편집: sixwwwwww 2013년 12월 16일
/matlabcentral/answers/uploaded_files/5868/final%20project.png Can anyone help me with the last 3 plots? you can see the paramters in the link

채택된 답변

sixwwwwww
sixwwwwww 2013년 12월 16일
편집: sixwwwwww 2013년 12월 16일
you can plot these shapes in the following two ways(you can choose better way you like):
%%Seashell
[u, v] = meshgrid(linspace(0, 6 * pi, 100), linspace(0, 2 * pi, 100));
x = 2 * (1 - exp(u / (6 * pi))) .* cos(u) .* (cos(0.5 * v))^2;
y = 2 * (-1 + exp(u / (6 * pi))) .* sin(u) .* (cos(0.5 * v))^2;
z = 1 - exp(u / (3 * pi)) - sin(v) + exp(u / (6 * pi)) .* sin(v);
figure, surf(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), title('Seashell')
%%Eight torus
c = 1;
[u, v] = meshgrid(linspace(-pi, pi, 100));
x = cos(u) .* (c + sin(v) .* cos(u) - sin(2 * v) .* (sin(u) / 2));
y = sin(u) .* (c + sin(v) .* cos(u) - sin(2 * v) .* (sin(u) / 2));
z = sin(u) .* sin(v) + cos(u) .* (sin(2 * v) / 2);
figure, surf(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), title('Eight torus')
%%Helical spring
r1 = 0.25;
r2 = 0.25;
T = 2;
n = 6;
[u, v] = meshgrid(linspace(0, 2 * n * pi, 100), linspace(0, 2 * pi, 100));
x = (1 - r1 * cos(v)) .* cos(u);
y = (1 - r1 * cos(v)) .* sin(u);
z = r2 * (sin(v) + T * u / pi);
figure, surf(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), title('Helical spring')
%%Cornucopia
a = 0.3;
b = 0.5;
[u, v] = meshgrid(linspace(0, 2 * pi, 100), linspace(-3, 3, 100));
x = exp(b * v) .* cos(v) + exp(a * v) .* cos(u) .* cos(v);
y = exp(b * v) .* sin(v) + exp(a * v) .* cos(u) .* sin(v);
z = exp(a * v) .* sin(u);
figure, surf(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), title('Cornucopia')
Or alternatively you can also plot them using ezsurf as follows:
syms u v
%%Seashell
x = 2 * (1 - exp(u / (6 * pi))) * cos(u) * (cos(0.5 * v))^2;
y = 2 * (-1 + exp(u / (6 * pi))) * sin(u) * (cos(0.5 * v))^2;
z = 1 - exp(u / (3 * pi)) - sin(v) + exp(u / (6 * pi)) * sin(v);
figure, ezsurf(x, y, z)
%%Eight torus
c = 1;
x = cos(u) * (c + sin(v) * cos(u) - sin(2 * v) * (sin(u) / 2));
y = sin(u) * (c + sin(v) * cos(u) - sin(2 * v) * (sin(u) / 2));
z = sin(u) * sin(v) + cos(u) * (sin(2 * v) / 2);
figure, ezsurf(x, y, z)
%%Helical spring
r1 = 0.25;
r2 = 0.25;
T = 2;
n = 6;
x = (1 - r1 * cos(v)) .* cos(u);
y = (1 - r1 * cos(v)) .* sin(u);
z = r2 * (sin(v) + T * u / pi);
figure, ezsurf(x, y, z)
%%Cornucopia
a = 0.3;
b =0.5;
x = exp(b * v) .* cos(v) + exp(a * v) .* cos(u) .* cos(v);
y = exp(b * v) .* sin(v) + exp(a * v) .* cos(u) .* sin(v);
z = exp(a * v) .* sin(u);
figure, ezsurf(x, y, z)
I hope it helps. Good luck!

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by