# fitting a bez spline to a semi-circle

This topic is 4942 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi did a search for similar topic but found nothing... having 2 endpoints i would like to find the third cv of a (2 degree) spline which produce exactly a semi-circle centered in the mid of the two ednpoints. Anyone knows if the pos of this third point can be calculated ( without using proper curve fitting) ? thanks

##### Share on other sites
Quote:
 Original post by mizar77hidid a search for similar topic but found nothing...having 2 endpoints i would like to find the third cv of a (2 degree) splinewhich produce exactly a semi-circle centered in the mid of the two ednpoints.Anyone knows if the pos of this third point can be calculated ( without using proper curve fitting) ?thanks

maybe you mean approximating a semi-circle?

##### Share on other sites
well.. yeah

first question should be: is it possible to approximate a semi-circle using a 2 degree bez spline?
if yes how do I calculate the middle control point?

##### Share on other sites
You cannot exactly represent a circle with a nonrational Bezier curve. You definitely can do it with non-uniform rational B-splines (NURBS), but that's a bit more involved.

You cannot really do a decent approximation of a semicircle with a 2-degree Bezier curve. Reason being, it is impossible to match the tangents at the two endpoints. But you can try to do something like this:

         ......    .....      ..... ....              ......                    ...                      .

You can do a decent approximation with a 3-degree Bezier curve. There would be two interior control points. Fit a box to the semicircle, and place one interior control point at each of the top corners of the box. I'll try to draw it out here:

x------------------------x|                        ||         ......         ||    .....      .....    || ....              .... ||..                    ..||.                      .|x                        x

In this way, the tangent direction is matched at the two bottom endpoints *and* at the top middle point. The actual curvatures won't match, but it'll be a reasonably decent approximation.

Now, actually the box needs to be taller than the desired semicircle, since the Bezier curve won't actually touch the box. And, you can do some math to calculate how tall the box needs to be.

You could also do two quarter circles, each with a 2-degree Bezier curve. This is done in the same way, but in this case the box would exactly fit the quarter circle, as below:

x---------...x|    .....| ....|..|.x

##### Share on other sites
I nearly forgot of this post i'v made cos I didnt get any replies at first.

So the second solution ( 3degree bez) is fine for me

"Now, actually the box needs to be taller than the desired semicircle, since the Bezier curve won't actually touch the box. And, you can do some math to calculate how tall the box needs to be."

what's exactly this math?
If you can link me to a site with explanation is fine.

thanks again

##### Share on other sites

Found with google: "bezier circle" ;)

Cheers,
Drag0n

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 12
• 13
• 10
• 11
• 13
• ### Forum Statistics

• Total Topics
634096
• Total Posts
3015482
×