Generate a 3D cone from directing vector and aperture angle
16 views (last 30 days)
Show older comments
Hello,
I have a 3D vector, let's call it [Fx Fy Fz], an aperture angle theta and a set of coordinates for the vertex [Vx Vy Vz]. What I would like to do is generate a 3D cone [Cx Cy Cz] in order to append it in a 3D graph, so I would write mesh(Cx, Cy, Cz). [Fx Fy Fz] would be the "directing" vector, oriented from the vertex to the base disk center. I found this function and slighly modified it but I realized that it had a totally different approach :
function [X2,Y2,Z2] = cone_plot3(r,h,phi,theta,offset)
m = h/r;
[R,A] = meshgrid(linspace(0,r,50),linspace(0,2*pi,50));
X = R.*cos(A);
Y = R.*sin(A);
Z = m*R;
% Cone around the z-axis, point at the origin
X1 = X*cos(phi) - Z*sin(phi);
Y1 = Y;
Z1 = X*sin(phi) + Z*cos(phi);
% Previous cone, rotated by angle phi about the y-axis
X2 = X1*cos(theta) + offset(1);
Y2 = X1*sin(theta) + offset(2);
Z2 = Z1 + offset(3);
% Second cone rotated by angle theta about the z-axis
end
Thanks in advance for your help
0 Comments
Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!