PDA

View Full Version : Bezier Curves



Mungo
04-22-2004, 10:36 AM
I'm creating a function to make basis functions for bezier parametric curves. I realise that bezier curves go through the first and control points but none of the others. So far my function does output the correct first point but when it gets to the last point the result as always zero.

I use the formula Bi(t)=C(k, i)t(power of i)(1-t)(power of k-i)

C being the coefficiant and k and i being the row and element index values for pascals triangle.

Im using the parametric range[0, 1] and as you can see when you input 1 the result would always have to be 0 and therefore my last sample point wouldnt = the last control point.

Its a long winded explanation but I must be working something out wrong or maybe I'm doing it right and i just dont know it.

Any help??

brcain
04-22-2004, 01:20 PM
Originally posted by Mungo:

I use the formula Bi(t)=C(k, i)t(power of i)(1-t)(power of k-i)

Im using the parametric range[0, 1] and as you can see when you input 1 the result would always have to be 0
If you input 1 you should get: Bn,n = t(power of n).

C(n,n)=1 and (1-1)(power of n-n)=1. Rememeber anything to zeroth power is 1.

I assume by C you meant binomial coefficient function.

Mungo
04-22-2004, 11:42 PM
Even 0 to the power 0 is 1?? Eeee if so thats something i never knew.

Yup C was the binomial coefficient function.

Thanks very much for your help.

Overmind
04-23-2004, 01:39 AM
No, 0^0 is undefined, it should give NaN on standard floating point units...

Mungo
04-23-2004, 01:45 AM
see thats my problem im going to have 1-1 to a power which will always either give an error or just equal 0 when i need it to equal 1

brcain
04-23-2004, 05:52 AM
Originally posted by Overmind:
No, 0^0 is undefined, it should give NaN on standard floating point units...Mathematically 0^0 = 1. Consult your CRC handbook.

Your compiler may throw an exception with the pow(x,y) function when x,y=0. If so, you'll need to check the values rather than computing the function.

Visual C++ 6.0 and gcc3.2-7 (on RH8) handle pow(0,0) just fine.

#include <math.h>
#include <stdio.h>
int main(void)
{
printf("pow(0,0)=%f\n", pow(0,0));
}

pow(0,0)=1.000000

Mungo
04-23-2004, 07:27 AM
ive got it to work now. turned out the 1-1^0 wasnt the problem like i thought it was because as you were saying it does equal 1. Thanks for all your help!