-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbezpow.c
More file actions
executable file
·38 lines (29 loc) · 849 Bytes
/
bezpow.c
File metadata and controls
executable file
·38 lines (29 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
void bezier_to_power(degree,bez,coeff)
/* Converts Bezier form to power (monomial) form. Works on
one coordinate only.
Input: degree: degree of curve.
bez: coefficients of Bezier form
Output: coeff: coefficients of power form.
Remark: For a 2D curve, this routine needs to be called twice,
once for the x-coordinates and once for y.
*/
int degree;
float coeff[], bez[];
{
float i_factorial, n_r;
int i;
differences(degree,bez,coeff); /* compute forward differences */
/* and store them in coeff. */
/* Note that i_factorial is int. */
/* For high degrees: danger! */
coeff[0]=bez[0];
i_factorial=1;
n_r=1;
for (i=1; i<=degree; i++)
{
i_factorial=i_factorial*i;
n_r= n_r*(degree-i+1);
coeff[i]=n_r*coeff[i]/i_factorial;
}
}