How to calculate intersection between line and algebraic level-set?

82 Views Asked by At

Context:

The intersection between a line and a plane is something that is usually taught in a first course of Linear Algebra. We know the equation of a plane:

$$c_1x_1+c_2x_2+c_3x_3 + c_4\cdot 1 = 0$$

We can write this as ${\bf c}^T {\bf x} = 0$ if we stuff into column vectors: ${\bf c} = [c_1,c_2,c_3,c_4]^T$, ${\bf x} = [x_1,x_2,x_3,1]^T$. Now for $\bf x$ to be a line, let's say for instance $$[x_1,x_2,x_3]= [a_1,a_2,a_3] + s[b_1,b_2,b_3]^T, s\in \mathbb R$$

Now this will boil down to one real variable solution in the parameter $s$ which is as easily found as solving the equation of a line $y = kx+m$ which we probably saw in high school.

Question:

But what if we have a non-plane surface, say for example a polynomial we want to calculate intersection with?

How can this be calculated? In particular let's say we want to find the smallest $s>0$ which solves it.

Own work A special case could be $$(x_1-c_1)^2 + (x_2-c_2)^2 + (x_3-c_3)^2 -R^2 = 0$$

This is the equation of a sphere and if my calculations are correct, this boils down to a classical 2nd degree polynomial in 1 variable which we presumably also solved in high-school.

My intuition tells me that for any geometrical object which can be written

$$\sum_j c_{j}\prod_{\forall k\in \{1\cdots n\}} {x_k}^{e_{j,k}} = 0$$

for $e_{j,k} \in \mathbb N^+$

we will always be able to simplify to a polynomial in one real variable. Is this correct?

I base this guess on the fact that each $x_k$ will be a 1-degree polynomial in one variable in our parameter $s$ and that all polynomials in one variable are closed under multiplication and addition (which I hope is true).


Thanks to the answer I now managed to make my own solver.

enter image description here

OpenGL proved to be very nice in providing a parallell way to calculate such solutions very quickly.

1

There are 1 best solutions below

3
On

Let your line have the vector equation $\vec p=\vec p_0+s\vec d$, and the surface be the implicit $f(\vec p)=0.$

$$f(\vec p_0+s\vec d)=0=\phi(s)$$ is indeed a scalar equation in $s$. If $f$ is polynomial of degree $d$ in the coordinates, $\phi$ is indeed a univariate polynomial of degree $d$.

In some cases the equation is solvable analytically, in others it requires numerical methods.


In the case of a unit sphere centered a the origin, assuming that $\vec d$ is normalized, the equation is

$$(\vec p_0+s\vec d)^2=1=\vec p_0^2+2\vec p_0\vec ds+s^2$$ which is indeed an easy quadratic.