How can I find minimum distance between cone and a point ?
Cone properties :
position - $(0,0,z)$
radius - $R$
height - $h$
Point properties:
position - $(0,0,z_1)$
How can I find minimum distance between cone and a point ?
Cone properties :
position - $(0,0,z)$
radius - $R$
height - $h$
Point properties:
position - $(0,0,z_1)$
I assume a right cone.
Put all shapes into a cylindrical coordinate system $(\phi, r, h)$, such that the axis of the cone satisfies $r = 0$. Now, by symmetry of cone, you can throw away $\phi$ and work in two dimensions.
You now have an isosceles triangle with point $A$ at the top and $B$ on the bottom, closer to the given point $X$. Now, the distance is given by $\begin{cases}0 & X_h \geq B_h \wedge \vec{X}\cdot \vec{n} < \vec{A} \cdot \vec{n} \\B_h - X_h& X_h < B_h \wedge X_r < B_r \\AX^2-\Big(\frac{\vec{AX}\cdot\vec{AB}}{AB} \Big)^2 & \vec{AX}\cdot\vec{AB} \geq 0 \wedge \vec{BX}\cdot\vec{BA} \geq 0 \\ \min \{AX, BX\}& otherwise\end{cases}$
Here $X_h, X_r$ indicate the two coordinates of $X$, $\cdot$ is the inner product and $\vec{n}$ is a normal of $AB$ pointing outwards.
It is surely a mess, but I don't know is anything cleaner can be expected.
Similar to @KarolisJuodelė, we assume a right cone. and work in a 2D coordinate system (r,h).
Let the opening angle be $2\phi$, with $\phi = tan^{-1} ( \frac{r}{h} )$.
For any point X = ($X_r,X_h$), The answer is:
$X_rcos\phi-(h-X_h)sin\phi$
Derivation:
We would like to know the distance along the normal a point is from the surface of a right cone oriented along the z-axis. See figure 1.
Here, d is the distance along the normal to point X. W is the intersection of the normal with the Z axis. h and r are the dimensions of the cone. Intuitively, since the normal is orthogonal to the surface of the cone, we see that we can calculate $d = \Vert X - W \Vert - (h-W_h)sin\phi$.
Working in 2D (r,h) with the cone aligned on the h axis for simplicity.
W is along the h axis, so $W_r=0$. Also, we can see that the slope of the normal is $\frac{r}{h}=tan\phi$, because the slope is orthogonal to the surface. We rewrite $W_h$ in terms of X. $W_h = X_h-X_r tan\phi$. We continue, substituting for W.
This can be intuitively seen using similar triangles as shown in figure 2.