Find equation for a parabolic line that goes through two points in 3D space I'm currently working on some computer graphics program where I want to show a line that "bounces" from point $A$ to point $B$, so I need an equation through which I can plug in values and interpolate the points that would trace the bounce.
Given two points, $A$ and $B$, in three dimensions, how do I determine the equation of a parabola that goes through $A$ and $B$?
Some additional information that might be helpful:

*

*Assume that a point $C$ is the midpoint between $A$ and $B$

*Assume that a point $D$ is the vertex of the parabolic line

*The length of line segment $\overline{CD}$ is a known variable/value


 A: Let's first specify the line from $A$ to $B$:
$$
u(\lambda) = (1-\lambda) A + \lambda B
$$
where $\lambda \in [0, 1]$.
Now we stack the parabola on top:
$$
f(\lambda) = (\lambda - 0)(\lambda - 1) h
$$
where $h$ is such that $f(1/2) = \vec{CD}$, which is the vector from $C$ to $D$:
$$
f(1/2) = (1/2)(1/2 - 1) h = \vec{CD} \iff \\
h = -4 \cdot \vec{CD} \iff \\
f(\lambda) = 4 \, \vec{CD} \, \lambda(1 - \lambda) 
$$
This gives
$$
v(\lambda) = (1-\lambda) A + \lambda B  + 4\, \vec{CD} \, \lambda(1-\lambda)
$$
This requires $C = (A+B)/2$. That way $A$ and $B$ can be arbitrary points, they need not lie in the $z=0$ plane.
A: You can use the quadratic Bezier curve whose three control points are $A$, $B$, and $E = 2D - C$. The first two are obvious. The third one, $E$, is a point that's vertically above $C$, at a height that's double the height of $D$.
The parametric equation of the curve is
$$
P(t) = (1-t)^2A + 2t(1-t)E + t^2B
$$
It's easy to confirm that $P(0)=A$, $P(1)=B$, and
\begin{aligned}
P(\tfrac12) &= \tfrac14A + \tfrac12E + \tfrac14B \\
&= \tfrac12(\tfrac12A + \tfrac12B) + \tfrac12(2D-C) \\
&= \tfrac12C + D - \tfrac12C \\
&= D
\end{aligned}
Or, if there's no good reason to use the Bezier form of the curve, you can express it in an even simpler manner by using quadratic Lagrange interpolation. The equation is
$$
P(t) = (1-3t+2t^2)A + (4t - 4t^2)D + (2t^2-t)B
$$
Again, it's easy to confirm that $P(0)=A$, $P(\tfrac12) = D$, and $P(1)=B$.
A: If you're familiar with some linear algebra, you could use the basis vectors $C-A$ and $(0,0,d)$, where $d=||D-C||$ (the vertical distance between $D$ and $C$) to form a vector space in $\mathbb{R}^2$ in which your parabola lies. In this vector space, the parabola would just be $y=1-x^2$, or $\vec{c}(t)=(t,1-t^2)$. Then all we need is the change of basis matrix from our vector space to $\mathbb{R}^3$, which is pretty easy because its columns are the basis vectors:
$\begin{pmatrix}
| & 0 \\
C-A & 0 \\
| & d
\end{pmatrix}$.
If we let $A=(a_0,a_1,a_2)$ and $C=(c_0,c_1,c_2)$, this means our matrix is
$\begin{pmatrix}
c_0-a_0 & 0 \\
c_1-a_1 & 0 \\
c_2-a_2 & d
\end{pmatrix}$.
We can multiply our parabola by this matrix and shift by $C$ (because in our original $\vec{c}(t)$, the origin is in the place of $C$) to get an equation for the parabola in $\mathbb{R}^3$:
$\begin{align}\vec{c}(t)=C+
\begin{pmatrix}
c_0-a_0 & 0 \\
c_1-a_1 & 0 \\
c_2-a_2 & d
\end{pmatrix}
\begin{pmatrix}
t \\
1-t^2
\end{pmatrix}&=C+
\begin{pmatrix}
(c_0-a_0)t \\
(c_1-a_1)t \\
(c_2-a_2)t+d(1-t^2)
\end{pmatrix}\\
&=C+(C-A)t+(D-C)(1-t^2)
\end{align}$
Here's a geogebra file demonstration: https://www.geogebra.org/calculator/rmfxuuft
