Algorithm to calculate the positions of bezier curve control point handles to transform from circle to straight line

208 Views Asked by At

From the image linked below (in A, I don't have enough points to add it directly) I have approximated two bezier cubic curve segments to a circle. I know how to move the anchor points AP1 and AP3 along the bigger circle to the desired position using the following (for AP1 for 90 degrees):

    var zeroAngleDirection = (AP1 - AP2).normalized;

    var twist = Vector3(0, 0, angle);

    AP1 = AP2 + twist * zeroAngleDirection * Vector2.Distance(AP1, AP2);

I want to arrive at the straight line in red marked in B. How can I rotate the control points as I reduce their length so that I'll arrive at the straight line, with AP1 = CP1 and so on?

Bezier Curve Circle and straight line

Please note that answers don't necessarily have to be in the same form as the code I provided above. I am just showing what I've been able to achieve so far.