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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| double BezierGen(int m,double u,int i);
double puissance(double a,int b);
int main()
{
double ptfinal[2];
ptfinal[1] = 0;
ptfinal[2] = 0;
double points2[4][2]; //tableaux qui contiendra les nouvelles valeurs
double points[4][2]; // tableaux contenant des ordonnées et des abscisses
points[1][1] = 0;
points[1][2] = 1;
points[2][1] = 2;
points[2][2] = 2;
points[3][1] = 4;
points[3][2] = 0;
points[4][1] = 5;
points[4][2] = 3;
double u = 0.25;
int m,i,j =0;
m = 3;
for (i=1;i<5;i=i+1)// parcours des lignes de mon tableau "points"
{
for(j=1;j<3;j=j+1)// parcours des colonnes de mon tableau "points"
{
double temp1,temp2;
temp1 = points[i][j];
temp2 = BezierGen(m,u,i-1);//fonction de calcul
points2[i][j] = temp1 * temp2 ;
}
}
for (i=1;i<3;i=i+1) // normalement je parcours les colonnes du tableaux points2
{
for(j=1;j<5;j=j+1)
{
printf("%lf\n",ptfinal[i]); //la il m'affiche la valeur de points2[4][1]
}
}
printf("x=%lf|y=%lf",ptfinal[1],ptfinal[2]);
system("PAUSE");
return 0;
}
double puissance(double a,int b)
{
int i;
double result;
result = a;
if (b == 0) return 1;
if (b == 1) return result;
if (b > 1)
{
for (i=2;i<=b;i++)
{
result = result * a;
}
return result;
}
}
int factorielle(int n)
{
if (n == 0) return 1;
if (n > 2) return n * factorielle(n - 1);
return n;
}
double BezierGen(int m,double u,int i)
{
return (factorielle(m)/(factorielle(m-i)*factorielle(i)))*puissance(u,i)*puissance((1-u),(m-i));
} |
Partager