$$C$$ = Point at the center of the base of the cone
$$H$$ = Point at the tip of the cone
$$r$$ = Cone base radius
$$P$$ = Point on the cone surface

$$L_{0}$$ = Point on the line
$$\mathbf{v}$$ = Vector that defines the line direction
Parametric equation of a point on the cone A generic point on the cone satisfies the equation: $\frac{\left\lVert P - Q \right\rVert}{\left\lVert Q - H \right\rVert} = \frac{r}{\left\lVert C - H \right\rVert}$ The vector $$\mathbf{h}$$ represents the axis of the cone. $\mathbf{h} = \left( C - H \right) \qquad \mathbf{\hat{h}} = \frac{\left( C - H \right)}{\left\lVert C - H \right\rVert}$ Both sides of the equation can be raised by the power of 2, to simplify the calculations. $\frac{\left\lVert P - Q \right\rVert^{2}}{\left\lVert Q - H \right\rVert^{2}} = \frac{r^{2}}{\left\lVert \mathbf{h} \right\rVert^{2}}$ Both the height and the base radius of the cone are caracteristic of the geometry and can be substituted by a constant. $m = \frac{r^{2}}{\left\lVert \mathbf{h} \right\rVert^{2}}$ $\left\lVert P - Q \right\rVert^{2} = m \left\lVert Q - H \right\rVert^{2}$ The segment $$\overline{HQ}$$ can be expressed in terms of $$P$$ as: $\left\lVert Q - H \right\rVert^{2} = \left[ \left( P - H \right) \cdot \mathbf{\hat{h}} \right]^{2}$ and substituted in the original equation. $\left\lVert P - Q \right\rVert^{2} = m \left[ \left( P - H \right) \cdot \mathbf{\hat{h}} \right]^{2}$ According to Pithagoras the squared length of $$\overline{QP}$$ can be obtained as the result of the length squared of $$\overline{HP}$$ minus the length squared of $$\overline{HQ}$$: $\left\lVert P - Q \right\rVert^{2} = \left\lVert P - H \right\rVert^{2} - \left\lVert Q - H \right\rVert^{2}$ and substituted in the original equation, along wth the squared length of the $$\overline{HQ}$$ $\left\lVert P - H \right\rVert^{2} - \left[ \left( P - H \right) \cdot \mathbf{\hat{h}} \right]^{2} = m \left[ \left( P - H \right) \cdot \mathbf{\hat{h}} \right]^{2}$ Parametric equation of the line A generic line defined by a point $$L_{0}$$ and a direction vector $$\mathbf{v}$$. It describes all the points along the line as a function of the parameter $$t$$. $L_{\left( t \right)} = L_{0} + t \mathbf{v}$ Intersections calculation To calculate the intersection between cone and line, substitute the generic point $$P$$ on the cone with a generic point on the line $$L_{(t)}$$. $\left\lVert L_{0} + t \mathbf{v} - H \right\rVert^{2} = \left( m + 1 \right) \left[ \left( L_{0} + t \mathbf{v} - H \right) \cdot \mathbf{\hat{h}} \right]^{2}$ Define a vector $$\mathbf{w}$$ equal to the difference of $$L_{0}$$ and $$H$$: $\mathbf{w} = L_{0} - H$ and substitute back. $\left\lVert t \mathbf{v} + \mathbf{w} \right\rVert^{2} = \left( m + 1 \right) \left[ \left( t \mathbf{v} + \mathbf{w} \right) \cdot \mathbf{\hat{h}} \right]^{2}$ The length squared of a vector is equal to the dot product of the vector by itself. $\left( t \mathbf{v} + \mathbf{w} \right) \cdot \left( t \mathbf{v} + \mathbf{w} \right) = \left( m + 1 \right) \left[ \left( \mathbf{v} \cdot \mathbf{\hat{h}} \right) t + \left( \mathbf{w} \cdot \mathbf{\hat{h}} \right) \right]^{2}$ Expand the dot product and the power. $\left( \mathbf{v} \cdot \mathbf{v} \right) t^{2} + 2 \left( \mathbf{v} \cdot \mathbf{w} \right) t + \left( \mathbf{w} \cdot \mathbf{w} \right) = \left( m + 1 \right) \left[ \left( \mathbf{v} \cdot \mathbf{\hat{h}} \right)^{2} t^{2} + 2 \left( \mathbf{v} \cdot \mathbf{\hat{h}} \right) \left( \mathbf{w} \cdot \mathbf{\hat{h}} \right) t + \left( \mathbf{w} \cdot \mathbf{\hat{h}} \right)^{2} \right]$ Group by the coefficients of $$t$$. $\begin{split} \left[ \left( \mathbf{v} \cdot \mathbf{v} \right) - \left( m + 1 \right) \left( \mathbf{v} \cdot \mathbf{\hat{h}} \right)^{2} \right] t^{2} + 2 \left\{ \left( \mathbf{v} \cdot \mathbf{w} \right) - \left( m + 1 \right) \left[ \left( \mathbf{v} \cdot \mathbf{\hat{h}} \right) \left( \mathbf{w} \cdot \mathbf{\hat{h}} \right) \right] \right\} t + \\ + \left( \mathbf{w} \cdot \mathbf{w} \right) - \left( m + 1 \right) \left( \mathbf{w} \cdot \mathbf{\hat{h}} \right)^{2} = 0 \end{split}$ Substitute the coefficients of $$t$$ to obtain a simpler quadratic equation. $\begin{cases} a = \left( \mathbf{v} \cdot \mathbf{v} \right) - m \left( \mathbf{v} \cdot \mathbf{\hat{h}} \right)^{2} - \left( \mathbf{v} \cdot \mathbf{\hat{h}} \right)^{2} \\ b = 2 \left[ \left( \mathbf{v} \cdot \mathbf{w} \right) - m \left( \mathbf{v} \cdot \mathbf{\hat{h}} \right) \left( \mathbf{w} \cdot \mathbf{\hat{h}} \right) - \left( \mathbf{v} \cdot \mathbf{\hat{h}} \right) \left( \mathbf{w} \cdot \mathbf{\hat{h}} \right) \right] \\ c = \left( \mathbf{w} \cdot \mathbf{w} \right) - m \left( \mathbf{w} \cdot \mathbf{\hat{h}} \right)^{2} - \left( \mathbf{w} \cdot \mathbf{\hat{h}} \right)^{2} \end{cases}$ Solve for $$t$$. $a t^{2} + b t + c = 0$ Intersection points
• if $$\left( b^{2} - 4 a c \right) > 0$$
There are two intersections at: $L_{int_{1,2}} = L_{0} + t_{1,2} \mathbf{v} \qquad t_{1,2} = \frac{ - b \pm \sqrt{ b^{2} - 4 a c } }{ 2 a }$

• if $$\left( b^{2} - 4 a c \right) = 0$$
The line $$L_{ \left( t \right) }$$ is tangent to the cone. $\left\lVert \mathbf{h} \right\rVert = cos \left( \alpha \right) \sqrt{\left\lVert \mathbf{h} \right\rVert^{2} + r^{2} } \qquad cos \left( \alpha \right) = \frac{\left\lVert \mathbf{h} \right\rVert}{\sqrt{\left\lVert \mathbf{h} \right\rVert^{2} + r^{2} }}$
• if $$\left| \mathbf{\hat{v}} \cdot \mathbf{\hat{h}} \right| \neq cos \left( \alpha \right)$$
There is one intersection at: $L_{int} = L_{0} + t \mathbf{v} \qquad t = - \frac{ b }{ 2 a }$

• if $$\left| \mathbf{\hat{v}} \cdot \mathbf{\hat{h}} \right| = cos \left( \alpha \right)$$
The line $$L_{ \left( t \right) }$$ lies on the cone surface. There are infinite intersections.

• if $$\left( b^{2} - 4 a c \right) < 0$$
There are no intersections.

If any intersections are found and the cone is not infinite, the projection of the intersections on the cone axis must be between the two extremities $$H$$ and $$C$$.

• if $$0 \leq \left( L_{int} - C \right) \cdot \mathbf{h} \leq \left\lVert \mathbf{h} \right\rVert$$
The intersection is on the cone surface.

• if $$\left( L_{int} - C \right) \cdot \mathbf{h} > \left\lVert \mathbf{h} \right\rVert$$
The intersection is below the base of the cone. Test the intersection with the cone base cap.

• if $$\left( L_{int} - C \right) \cdot \mathbf{h} < 0$$
The intersection is above the top of the cone.