0
$\begingroup$

Given a segment defined by two points in $\Bbb{R}^3$, $P_0$ and $P_1$ and a cone defined by an origin $C_0$ and axis $\vec{C}$ and a cone angle $\phi$ how to find either the minimum distance of the segment to the cone if it is not intersecting or the penetration depth of the segment if it is intersecting.

To clarify what distance and penetration depth means:

  1. Distance is the distance one must offset a non intersecting cone so that it is just touching the segment.
  2. Penetration depth is the distance one must offset an intersecting cone so that it no longer intersecting and is just touching the segment.

Thus 1 and 2 are actually identical and can be considered a signed distance. The result required is the offset from the reference cone so that the segment is outside the cone and just touching.

The cone is only interesting on the positive side of the $\vec{C}$

$\endgroup$
8
  • $\begingroup$ For 1. I imagine that you mean the minimum offset distance, whatever the direction. $\endgroup$ May 31 at 16:12
  • $\begingroup$ Yes that is what I mean. The answer could be positive or negative. $\endgroup$ May 31 at 16:14
  • $\begingroup$ Currently I use a variation on point to cone distance and find the minimum over the segment using a brent solver. But that is fast for a single segment and slow when I have a million segments. Hoping for a direct solution if it exists. $\endgroup$ May 31 at 16:16
  • $\begingroup$ There exists most likely a direct solution. Have you first looked at the problem where the segment is replaced with an (infinite) line? $\endgroup$ May 31 at 16:18
  • $\begingroup$ That would probably be simpler but there are obviously cases when the infinite line penetrates the infinite cone and no offsetting will change that. That condition is when the angle between the line and the cone axis is less thant $\phi/2$ $\endgroup$ May 31 at 16:20
1
$\begingroup$

The idea is to project $P_0P_1$ along $\vec C$ until it gets in contact with the cone. To reduce the complexity:

  • Translate and rotate the scene so that $C_0$ is in the origin and $\vec C$ is pointing along positive $z$ direction.
  • Rotate the scene around $z$ so that the transformed $P_0$ and $P_1$ have equal $y$ coordinates. Rotation angle can be found from normal of segment projection onto XoY plane.

You should get this scene when view from the top

this scene when viewed from the top.

Transformed segment lies in YoZ-parallel plane. This plane is creating hyperbolic section on conic surface. We can find the shortest distance along $z$ between hyperbola and line segment

between hyperbola and line segment,

which should give the answer. Closest points would either be segment ends or a witness point of hyperbola vertex projection onto the segment. There are some corner cases to be handled though like segment being parallel to generatrix of a cone or dealing with axial section.

$\endgroup$
1
  • $\begingroup$ @bradgonesurfing I voted to reject your "gif" edit as I felt it would be better if you suggested this edit in a comment to the answer. It is quite a significant edit so I feel that pabababa should have the main say in it. $\endgroup$
    – user1729
    Jun 2 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.