- (x,y) coordinates of the 2D spiral
- (X,Y,Z) coordinates of the 3D surface
How to project and fit a 2D path onto a 3D surface?
21 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mohamed Ibraheem
le 28 Déc 2021
Réponse apportée : Adam Danz
le 28 Déc 2021
I want to project a 2D spiral path on a 3D surface as in the attached image. How can this be done? Any help would be appreciated.
0 commentaires
Réponse acceptée
Adam Danz
le 28 Déc 2021
> I want to project a 2D spiral path on a 3D surface
Inputs:
Produce 2D spiral.
t = linspace(0,12*pi,201);
x = t/pi.*cos(t);
y = t/pi.*sin(t);
zBase = -8;
z = zBase * ones(size(x));
cla()
plot3(x,y,z, '-', 'Color', [0.5 0.5 0.5])
Produce 3D surface
% Define surface
hold on
[X,Y,Z] = peaks(25);
X = X*4;
Y = Y*4;
% surf(X,Y,Z)
Interpolate the 3D surface so it shares the same x,y grid values as the spiral.
F = griddedInterpolant(X',Y',Z');
[Xq,Yq] = ndgrid(x,y);
Vq = F(Xq,Yq);
% Plot the interpolated surface
surf(Xq,Yq,Vq,'FaceAlpha',.1,'EdgeAlpha',0)
Add the 3D spiral to the surface
z3D = Vq(logical(eye(size(Vq))));
plot3(x,y,z3D, 'k-', 'LineWidth', 1)
0 commentaires
Plus de réponses (1)
DGM
le 28 Déc 2021
Something like
N = 1000;
nturns = 10;
rmax = pi;
zscale = 0.1;
zoffset = 0.5;
r = linspace(0,rmax,N);
th = linspace(0,nturns*2*pi,N);
[x y] = pol2cart(th,r);
z = zoffset + zscale*sin(x);
plot(x,y); hold on
plot3(x,y,z);
view(3)
zlim([0 1])
view(-15,14)
0 commentaires
Voir également
Catégories
En savoir plus sur Thermal Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!