I have points around a circle that I want to connect with quadratic bezier curves. For every curve I draw, it starts at (x1,y1) on the circle, gets bent by the control point (centerX,centerY), and finishes at (x2,y2) on the circle.

I currently calculate the control points for a particular curve like this:

void calculate( int x1, int x2, int y1, int y2, int centerOfCircleXCoordinate, int centerOfCircleYCoordinate ) { // Calculate the midpoint between the two points. int midX = ( x1 + x2 ) / 2; int midY = ( y1 + y2 ) / 2; // Calculate the distance between the two points, and the angle at which a perpendicular line, // extending toward the center of the circle, would extend from the midpoint. double distance = sqrt( pow( x2 - x1, 2 ) + pow( y2 - y1, 2 ) ); double angle = atan2( midY - centerOfCircleYCoordinate, midX - centerOfCircleXCoordinate ); // Calculate the length of the perpendicular line, and its x and y components. double altitude = sqrt( 0.75 * pow ( distance, 2 ) ); int altitudeX = (int)( cos( angle ) * altitude ); int altitudeY = (int)( sin( angle ) * altitude ); // Calculate the control point by subtracting half of the altitude from the midpoint. int centerX = midX - ( altitudeX / 2 ); int centerY = midY - ( altitudeY / 2 ); /* More stuff follows, but isn't important here. */ }

Essentially, I calculate the control points right now so the arcs are half as tall as the distance between their end points. For the most part, this works well, but there are many instances that curves cross (from across the circle, for example) when they shouldn't. So, I came up with the idea of having the curves bend less (be more like straight lines), the closer their midpoints come to the center of the circle. Unfortunately, this is where I'm stuck.

I've tried making a proportion based on the ratio of the altitude to the radius, but that was the only idea I had, and it didn't work.

Would anyone mind pointing me in the right direction to calculate the proper control points which bend these curves, please? I'd appreciate any help.

Thanks,

Zel2008