I've been stuck on this for 2 weeks and have not had much luck asking else where either.
I have a curve, which is an arc, at each end of the arc there is tangent vector which is sloped in some direction on the Y axis, these tangents are unit vectors that just point in some direction at the end points of the arc, a visual of what I am trying to create here:
The arc is from a circle so its a perfect arc when projected flat, I am slicing this arc into a series of smaller bezier curves < 90 degrees each as an approximation to keep it accurate.
The problem is I can't figure out the control points for the Bézier curves to match the slope along this arc for the arc's tangent.
This is my current attempt:
I can find the horizontal displacement for the bezier curve of the arc quite easily, as you can see it winds around the arc perfectly but the vertical component of the control points I cannot figure out.
The Bézier curve is calculated like this:
// convert a slice of the full curve to bezier
// origin, radius, from, to, angleBetween from and to
c = tan(angle / 4) * 4 / 3f * radius
pt1 = from
ctrlPt1 = from + Perpendicular(from - origin).normalized * c
ctrlPt2 = to + Perpendicular(to - origin).normalized * c
pt2 = to
// need to now adjust ctrlPt1 and ctrlPt2 to give them correct slope, not sure how to calculate
Using this function, you can see it just finds "flat" control points and gives a wonky curve that levels off at each end of the Bézier curve:
This is how it was suppose to look (drawn in white.. poorly with the mouse):
How do you calculate the correct control point positions to match the desired end tangents of the full arc for each sliced Bézier curve? I can't figure out the math at all.