Mathc initiation/a256
Apparence
Installer ce fichier dans votre répertoire de travail.
k3bezier.h |
---|
/* --------------------------------- */
/* save as k3bezier.h */
/* --------------------------------- */
void G_3_quartic_Bezier_2d(
CTRL_splot w,
pt2d P0,
pt2d P1,
pt2d P2,
pt2d P3,
pt2d P4,
pt2d P5,
pt2d P6,
pt2d P7,
pt2d P8,
pt2d P9,
pt2d P10,
pt2d P11,
pt2d P12
)
{
tvalue t;
t.min = 0;
t.max = 1;
t.step = .01;
FILE *fp = fopen("a_main.plt","w");
fprintf(fp," set zeroaxis lt 8\n"
" set grid\n\n"
" reset\n"
" plot [%0.3f:%0.3f] [%0.3f:%0.3f]\\\n"
" \"curve1\" with linesp lt 3 pt 1,\\\n"
" \"curve2\" with linesp lt 3 pt 1,\\\n"
" \"curve3\" with linesp lt 3 pt 1,\\\n"
" \"ctrlpt1\" with linesp lt 4 pt 4,\\\n"
" \"ctrlpt2\" with linesp lt 4 pt 4,\\\n"
" \"ctrlpt3\" with linesp lt 4 pt 4\n\n",
w.xmin,w.xmax,w.ymin,w.ymax);
fclose(fp);
fp = fopen("curve1","w");
for(t.value=t.min; t.value<=t.max; t.value+=t.step)
fprintf(fp," %6.5f %6.5f\n",
quartic_Bezier_x_2d(t.value,P0,P1,P2,P3,P4),
quartic_Bezier_y_2d(t.value,P0,P1,P2,P3,P4));
fclose(fp);
fp = fopen("curve2","w");
for(t.value=t.min; t.value<=t.max; t.value+=t.step)
fprintf(fp," %6.5f %6.5f\n",
quartic_Bezier_x_2d(t.value,P4,P5,P6,P7,P8),
quartic_Bezier_y_2d(t.value,P4,P5,P6,P7,P8));
fclose(fp);
fp = fopen("curve3","w");
for(t.value=t.min; t.value<=t.max; t.value+=t.step)
fprintf(fp," %6.5f %6.5f\n",
quartic_Bezier_x_2d(t.value,P8,P9,P10,P11,P12),
quartic_Bezier_y_2d(t.value,P8,P9,P10,P11,P12));
fclose(fp);
fp = fopen("ctrlpt1","w");
fprintf(fp," %6.5f %6.5f\n",P0.x,P0.y);
fprintf(fp," %6.5f %6.5f\n",P1.x,P1.y);
fprintf(fp," %6.5f %6.5f\n",P2.x,P2.y);
fprintf(fp," %6.5f %6.5f\n",P3.x,P3.y);
fprintf(fp," %6.5f %6.5f\n",P4.x,P4.y);
fclose(fp);
fp = fopen("ctrlpt2","w");
fprintf(fp," %6.5f %6.5f\n",P4.x,P4.y);
fprintf(fp," %6.5f %6.5f\n",P5.x,P5.y);
fprintf(fp," %6.5f %6.5f\n",P6.x,P6.y);
fprintf(fp," %6.5f %6.5f\n",P7.x,P7.y);
fprintf(fp," %6.5f %6.5f\n",P8.x,P8.y);
fclose(fp);
fp = fopen("ctrlpt3","w");
fprintf(fp," %6.5f %6.5f\n",P8.x, P8.y);
fprintf(fp," %6.5f %6.5f\n",P9.x, P9.y);
fprintf(fp," %6.5f %6.5f\n",P10.x,P10.y);
fprintf(fp," %6.5f %6.5f\n",P11.x,P11.y);
fprintf(fp," %6.5f %6.5f\n",P12.x,P12.y);
fclose(fp);
}
/* --------------------------------- */
void G_3_wp_quartic_Bezier_2d(
CTRL_splot w,
pt2d P0,
pt2d P1,
pt2d P2,
pt2d P3,
pt2d P4,
pt2d P5,
pt2d P6,
pt2d P7,
pt2d P8,
pt2d P9,
pt2d P10,
pt2d P11,
pt2d P12
)
{
tvalue t;
t.min = 0;
t.max = 1;
t.step = .01;
FILE *fp = fopen("a_main.plt","w");
fprintf(fp," set zeroaxis lt 8\n"
" set grid\n\n"
" plot [%0.3f:%0.3f] [%0.3f:%0.3f]\\\n"
" \"curve1\" with linesp lt 3 pt 1,\\\n"
" \"curve2\" with linesp lt 3 pt 1,\\\n"
" \"curve3\" with linesp lt 3 pt 1",
w.xmin,w.xmax,w.ymin,w.ymax);
fclose(fp);
fp = fopen("curve1","w");
for(t.value=t.min; t.value<=t.max; t.value+=t.step)
fprintf(fp," %6.5f %6.5f\n",
quartic_Bezier_x_2d(t.value,P0,P1,P2,P3,P4),
quartic_Bezier_y_2d(t.value,P0,P1,P2,P3,P4));
fclose(fp);
fp = fopen("curve2","w");
for(t.value=t.min; t.value<=t.max; t.value+=t.step)
fprintf(fp," %6.5f %6.5f\n",
quartic_Bezier_x_2d(t.value,P4,P5,P6,P7,P8),
quartic_Bezier_y_2d(t.value,P4,P5,P6,P7,P8));
fclose(fp);
fp = fopen("curve3","w");
for(t.value=t.min; t.value<=t.max; t.value+=t.step)
fprintf(fp," %6.5f %6.5f\n",
quartic_Bezier_x_2d(t.value,P8,P9,P10,P11,P12),
quartic_Bezier_y_2d(t.value,P8,P9,P10,P11,P12));
fclose(fp);
}
/* --------------------------------- */
/* --------------------------------- */