Revolving a curve about the y-axis to generate a 3D surface
106 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Asser Abdelgawad
le 11 Mai 2022
Commenté : Asser Abdelgawad
le 13 Juin 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 commentaires
Réponse acceptée
John D'Errico
le 11 Mai 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.
Voir également
Catégories
En savoir plus sur Computational Geometry dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!