How would I plot conic sections in a 3D cone and extract certain parts of the graph?

22 vues (au cours des 30 derniers jours)
I'm a beginner and I don't have much MATLAB expericence, but I'm trying to draw different conic sections in a 3d cone and then extract just the intersection of the plane and the cone in order to highlight the different conics (parabolas, hyperbolas, etc) that are formed? Specifically, how would I simply extract the intersection between a plane and the cone?
It would be especially helpful if answers and code were in a simpler and more understandable format tailored to a beginner like me.
Thanks
Here is my current code
r = linspace(0,2*pi) ;
th = linspace(0,2*pi) ;
[R,T] = meshgrid(r,th) ;
X = R.*cos(T) ;
Y = R.*sin(T) ;
Z = R;
surf(X,Y,Z)
patch([2 -2 -2 2], [2 2 -2 -2], [2 2 2 2], [2 2 -2 -2])
hold on
surf(-X,-Y,-Z)
  1 commentaire
darova
darova le 21 Juin 2019
Use the same X and Y for plane. Use contour() to calculate intersection
Look HERE

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 21 Juin 2019
Modifié(e) : Matt J le 21 Juin 2019
The easiest would be to have the plane fixed as the xy-plane and just rotate/translate the cone around in 3D space to get different sections,
[R,~]=qr(rand(3)); %random rotation
R=R*det(R);
D=diag([1,1,-1]);
fcone=@(x,y,z)sum([x;y;z+1].*R.'*D*R*[x;y;z+1]); %3D cone
fsec= @(x,y) sum([x;y;1].*R.'*D*R*[x;y;1]); %2D intersection of cone with xy plane
hc=fimplicit3(fcone); %plot 3D cone
hc.MeshDensity=15;
hc.EdgeColor='none';
hc.FaceAlpha=0.1;
hold on
hsec=fimplicit(fsec); %plot section
hold off
legend('Cone','Section')
  2 commentaires
Satwik Misra
Satwik Misra le 21 Juin 2019
Thank you! Just curious, how would you go about graphing the ellipse shown in the second picture? Would you have to change fsec?
Matt J
Matt J le 21 Juin 2019
No. Each plot corresponds to a different R, randomly selected in this code.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Construction 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!

Translated by