Revolving a curve about the y-axis to generate a 3D surface
108 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Asser Abdelgawad
el 11 de Mayo de 2022
Comentada: Asser Abdelgawad
el 13 de Jun. de 2022
I'm aware that the cylinder() functiond does this for revolutions about the x-axis. But is there a way to do this about the y-axis?
0 comentarios
Respuesta aceptada
John D'Errico
el 11 de Mayo de 2022
Certainly. Just write the code yourself. Seriously, it is not difficult.
Consider the function y = f(x).
f = @(x) x.*(1-x);
fplot(f,[0,1])
We want to rotate this around the Y axis.
n = 100;
theta = linspace(0,2*pi,n).';
x0 = linspace(0,1,n);
y0 = f(x0);
x = x0.*cos(theta);
z = x0.*sin(theta);
y = repmat(y0,[n,1]);
surf(x,y,z)
xlabel x
ylabel y
zlabel z
view(20,30)
So the y axis lives at (x,z) = (0,0). The curve drawn in the original figure has been rotated around the y axis, producing this sideways cup, with a cusp at the center.
Ver también
Categorías
Más información sobre Computational Geometry en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!