Jump to content
  • Advertisement
Sign in to follow this  
mizar77

fitting a bez spline to a semi-circle

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by mizar77

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


maybe you mean approximating a semi-circle?

Share this post


Link to post
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 this post


Link to post
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:

This is your semicircle:


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


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 this post


Link to post
Share on other sites
thanks for the answer!
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!