-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpspln.c
executable file
·97 lines (73 loc) · 2.02 KB
/
pspln.c
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <stdio.h>
#include <math.h>
extern FILE *psfile;
void psplot_net(lu,lv,bx,by,step_u,step_v,scale_x,scale_y,value)
/* plots control net into postscript-file.
Input: lu,lv: dimensions of net
bx,by: net vertices
step_u,step_v: subnet sizes (e.g. both=3 for pw bicubic net)
scale_x,scale_y:scale factors for ps
value: window size in world coords
*/
int lu,lv,step_u,step_v;
float bx[20][20], by[20][20],value[4],scale_x,scale_y;
{
int lv1;
int i,j;
fprintf(psfile,"0.0 setgray \n");
fprintf(psfile,"1 setlinewidth\n");
lv1= lv+1;
for(i=0; i<= lu; i++)
{
fprintf(psfile,"newpath\n");
fprintf(psfile," %f %f moveto\n",
scale_x*(bx[i][0]-value[0]),
scale_y*(by[i][0]-value[2]));
for(j=1; j<= lv; j++)
fprintf(psfile,"%f %f lineto\n",
scale_x*(bx[i][j]-value[0]),
scale_y*(by[i][j]-value[2]));
fprintf(psfile,"stroke\n");
}
for(j=0;j<= lv;j++)
{
fprintf(psfile,"newpath\n");
fprintf(psfile," %f %f moveto\n",
scale_x*(bx[0][j]-value[0]),
scale_y*(by[0][j]-value[2]));
for(i=1; i<= lu; i++)
fprintf(psfile," %f %f lineto\n",
scale_x*(bx[i][j]-value[0]),
scale_y*(by[i][j]-value[2]));
fprintf(psfile,"stroke\n");
}
/***** now mark control points *****/
for(i=0; i<= lu; i++)
{
for(j=0; j<= lv; j++)
fprintf(psfile,"%f %f %f %f %f arc stroke\n",
scale_x*(bx[i][j]-value[0]),
scale_y*(by[i][j]-value[2]),
3.0, 0.0, 360.0);
}
fprintf(psfile,"1 setgray\n"); /* to white out circles */
for(i=0; i<= lu; i++)
{
for(j=0; j<= lv; j++)
fprintf(psfile,"%f %f %f %f %f arc fill\n",
scale_x*(bx[i][j]-value[0]),
scale_y*(by[i][j]-value[2]),
2.9, 0.0, 360.0);
}
/* subnet corners in black: */
fprintf(psfile,"0.0 setgray\n");
for(i=0; i<= lu; i+= step_u)
{
for(j=0; j<= lv; j+= step_v)
fprintf(psfile,"%f %f %f %f %f arc fill\n",
scale_x*(bx[i][j]-value[0]),
scale_y*(by[i][j]-value[2]),
2.9, 0.0, 360.0);
}
}