4

I am coding the intersection of a 3D Bézier curve with parametric equation and a parametric sphere equation, with the objective of splitting the Bézier curve at that specific point. Can you check my equations?

I define my sphere and Bézier as: $$\begin{array}{l}{X_s} = r*\cos (v)\cos (u)\\{Y_s} = r*\cos (v)\sin (u)\\{Z_s} = r*\sin (v)\\B(t) = {(1 - t)^3}{P_{01}} + 3(t - 2{t^2} - {t^3}){P_{11}} + 3({t^2} - {t^3}){P_{21}} + {t^3}{P_{31}}\end{array} $$

Under this equations my intersection is defined as:

$$\begin{array}{l}r*\cos (v)\cos (u) = {(1 - t)^3}{P_{01X}} + 3(t - 2{t^2} - {t^3}){P_{11X}} + 3({t^2} - {t^3}){P_{21X}} + {t^3}{P_{31X}}\\r*\cos (v)\sin (u) = {(1 - t)^3}{P_{01Y}} + 3(t - 2{t^2} - {t^3}){P_{11Y}} + 3({t^2} - {t^3}){P_{21Y}} + {t^3}{P_{31Y}}\\r*\sin (v) = {(1 - t)^3}{P_{01Z}} + 3(t - 2{t^2} - {t^3}){P_{11Z}} + 3({t^2} - {t^3}){P_{21Z}} + {t^3}{P_{31Z}}\end{array} $$

This gives me a system of three unknown $u,v,t$ and three equations. Am I correct? Is there a better way?

bubba
  • 43,483
  • 3
  • 61
  • 122

1 Answers1

2

You equations are correct, but there is a better way. You should use the implicit equation of the sphere. This is $x^2 + y^2 +z^2 =r^2$, which can also be written as $\| \mathbf X \|^2 = r^2$ or $\mathbf X \cdot \mathbf X = r^2$.

Solve the equation $\mathbf{B}(t) \cdot \mathbf{B}(t) = r^2$. Here the dot denotes a vector dot product.

This is a single polynomial equation of degree 6 in the variable $t$. You will still have to solve it using numerical methods, but this is much easier than solving a system of three equations in three unknowns.

bubba
  • 43,483
  • 3
  • 61
  • 122
  • Thank you for the answer and the edit,sorry for the errors. I was in a hurry for organizing other equations. – Wilmer Ariza Oct 21 '16 at 00:49
  • Why is this an equation of degree 6? It seems cosine must be equal to 1, isn't it? Then, $\mathbf{B}(t) = r$. Or where do I mistake? – Necronomicron Sep 15 '21 at 08:57
  • 1
    The dot represents the dot product of two vectors. Your equation $\mathbf{B}(t) = r$ doesn’t make sense because the left side is a vector and the right side is a scalar. – bubba Sep 15 '21 at 10:39
  • I don’t know what cosine you’re talking about. – bubba Sep 15 '21 at 10:41
  • 1
    You can use the equation $| \mathbf B (t) | = r$, if you want, but that will still have degree 6 after you remove the square root. – bubba Sep 15 '21 at 10:42
  • @bubba $\mathbf{a}\cdot\mathbf{b}=|\mathbf{a}|\ |\mathbf{b}|\cos\theta$ But you are right. So how do I solve it? I couldn't find an understandable way of solving sextic equation. – Necronomicron Sep 15 '21 at 10:58
  • You need numerical methods. You could start by looking in the “Numerical Recipes” book. – bubba Sep 16 '21 at 04:41