PDA

View Full Version : hermite/quadratic bezier curve vs (sin and cos)


arpace
Dec25-10, 04:51 AM
So I have a Hermite curve with the control points:

//point# (x,y):

p0 (1,0)
p1 (1,(Math.sqrt(2)-1))
p2 (Math.sqrt(0.5), Math.sqrt(0.5))

I also have the algorithm to find the points on the locus between 0 and 45 degrees:

//L0 is the point on the line between p0 and p1
//L1 is the point on the line between p1 and p2
//Loc is the point on the locus
//...
//keep in mind that although this can be extended with if statements to check for
//any degree with a little modification
//right now, the rule is 0 <= degree <= 45

L0 = p0 + (p1 - p0)*degree/45;
L1 = p1 + (p2 - p1)*degree/45;
Loc = L0 + (L1-L0)*degree/45;

so Shouldn't this, as it is essentially a quadratic Bezier (Hermite) curve representing degrees 0 through 45 of a unit circle , not equal the results of sind(degree) as long as:
0<= degree <= 45 ???


when I use for the degree 22.5, on my windows calculator
sind(22.5) = 0.3826834323650897717284599840304;

...but mine (again using the window calc) at 22.5 degrees is
Loc.y = 0.38388347648318440550105545263106

could this be due to floating point error? Is there something obvious I am missing?

here is an image I made to help with conceptualization
http://sphotos.ak.fbcdn.net/hphotos-ak-snc4/hs1384.snc4/163638_10100121877154282_28122817_59279302_5323393 _n.jpg

arpace
Dec27-10, 09:01 PM
seriously? no one?

AlephZero
Dec28-10, 01:39 PM
A Bezier curve can not be exactly equal to a circle.

Repeat the subdivision process again, and you will see that you a mid-point which is not a unit distance from the origin.

However your splines are a good approximations to a circle, and are often used to draw approximate circles in computer graphics.

FWIW it is possible to represent a circular arc up to a semicircle (or in fact any conic section) exactly using rational functions as splines. Look up the theory of NURBS (non-uniform rational B-splines) if you are interested.

timthereaper
Jan16-12, 02:54 PM
Actually, a quadratic rational Bezier curve can exactly reproduce a circular arc and a degree 5 rational Bezier curve can represent an entire circle. There is a formula to figure out the weights for each control point if you're still interested. A NURBS can reproduce any conic section, which makes them so versatile. However, a NURBS is basically a collection of Bezier curves joined together so that they have a specified continuity. If you're interested, there is a whole bunch of information about computer-aided geometric design at http://en.wikiversity.org/wiki/CAGD