General Plotting Code for Cone in 3D with GLMakie or Plots

From your questions posted on this forum it seems that you are teaching math. Hence you should explain to your students how is parameterized a general cone,
defined by its vertex V, given as a 3 vector, and a closed (but not necessarily) planar curve,

x = x(u)
y = y(u)
z= b # b from base plane; usually b=0

u \in [\alpha, \beta]
.
The cone is generated by all segments of line connecting its vertex, V, with the points
(x(u), y(u), b), on the base curve.
Such a segment has the equations:
\displaystyle\frac{X-V[1]}{x(u)-V[1]} = \displaystyle\frac{Y-V[2]}{y(u)-V[2]} =\displaystyle\frac{Z-V[3]}{b-V[3]}=v
Hence:

X = v(x(u)-V[1])+V[1]
Y = v(y(u)-V[2])+V[2]
Z = v(b-V[3])+V[3]

u \in [\alpha, \beta], v\in[0,1]
Example:

vert=[0, 0.75, 3] #cone vertex
base = 0 #the cone base is included within the plane z=base (here z=0)
#functions that define the cone base parameterization
x(u) = cos(u)
y(u) = sin(u)+ sin(u/2);
m, n = 72, 30
u= range(0, 2π, length=m)
v = range(0, 1, length=n)
us = ones(n)*u'
vs = v*ones(m)'
#Surface parameterization
X = @. vs* (x(us)-vert[1]) + vert[1]
Y = @. vs* (y(us)-vert[2]) + vert[2]
Z = @. vs*(base-vert[3]) + vert[3];
surface(X, Y, Z, size=(600,600), cbar=:none, legend=false) #line copied from Rafael 
2 Likes