Converting points in arc to a bezier curve

1.4k Views Asked by At

I have the coordinates of potentially any points within a 3D arc, representing the path an object will take when launched through the air. X is forward, Z is up, if that is relevant. Using any of these points, I need to create a bezier curve that follows this arc. The curve requires the tangent values for the very start and end of the curve. I can't figure out the formula needed to convert this arc into a bezier curve, and I'm hoping someone can help. I've found plenty of resources discussing circular arcs, but the arc here is not circular.

2

There are 2 best solutions below

1
On

Assuming that the arc is indeed a parabola, then the procedures outlined at Convert segment of parabola to quadratic bezier curve and http://www.ams.org/samplings/feature-column/fcarc-bezier should provide the appropriate calculations.

7
On

Let $\mathbf{Q}$ be the start of the curve, let $\mathbf{V}$ be the initial velocity vector, and let $\mathbf{G}$ be the gravity vector. Then the equation of the trajectory is: $$ \text{ParabolaFunction:}\quad \mathbf{P}(t) = \mathbf{Q} + t\mathbf{V} + \tfrac12 t^2\mathbf{G} $$ I will assume that you have unitized the time scale so that the flight starts at $t=0$ and ends at $t=1$.

Compute three points on the curve: \begin{align} \mathbf{P}_0 &= \mathbf{P}(0) \\ \mathbf{P}_m &= \mathbf{P}(\tfrac12) \\ \mathbf{P}_3 &= \mathbf{P}(1) \end{align} and let $\mathbf{P}_c = \tfrac12(\mathbf{P}_0 + \mathbf{P}_1)$ be the mid-point. Compute $$ \mathbf{P}_a = \mathbf{P}_c + 2(\mathbf{P}_m - \mathbf{P}_c). $$ Then let \begin{align} \mathbf{P}_1 &= \tfrac23\mathbf{P}_a + \tfrac13\mathbf{P}_0 \\ \mathbf{P}_2 &= \tfrac23\mathbf{P}_a + \tfrac13\mathbf{P}_3 \end{align} Then the control points of the cubic Bezier curve are $\mathbf{P}_0$, $\mathbf{P}_1$, $\mathbf{P}_2$, $\mathbf{P}_3$.

Pseudocode is as follows. It assumes that addition and scalar multiplication of 3D points and vectors have been overloaded in the obvious way:

p0 = ParabolaFunction(0)
pm = ParabolaFunction(0.5)
p3 = ParabolaFunction(1)

pc = 0.5*(p0 + p3)      // Point on chord
pa = pc + 2*(pm - cc)   // Apex point; intersection of tangents

oneThird = 1.0/3.0
twoThirds = 2*oneThird 

p1 = twoThirds*pa + oneThird*p0
p2 = twoThirds*pa + oneThird*p3

result = CubicBezierCurve(p0, p1, p2, p3)