forked from unihedron/spectrum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscale.c
77 lines (55 loc) · 1.77 KB
/
scale.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
#include<stdio.h>
#include<math.h>
/* Description:
Generate scale for spectrum chart:
input and begining and step frequency
output LaTeX for scale
n n n
|_._._._._|_._._._._|_._._._
*/
int main()
{
double point,xpos, start, end,step, startxpos, startypos, endxpos, endypos, position,width;
int ypos;
width=9.8;/*inches*/
printf("Generate scale for spectrum chart.\n");
printf("Enter three space separated frequencies Eg. 300e12 400e12 10e11\n");
printf(" exa e18.\n");
printf(" peta e15.\n");
printf(" tera e12.\n");
printf(" giga e9.\n");
printf(" mega e6.\n");
printf(" x step is 0.5 inches.\n");
printf(" y divided into 12 steps.\n");
printf("Ctl-c to exit.\n");
while (scanf("%lf %lf %lf", &start, &end, &step) == 3){
for (point=start;point<=end;point=point+step){
/*calculate the X and Y positions for a point */
position = log(point)/log(2);
ypos = (int)position;
startxpos = ((position-(double)ypos))*width;
startypos = (double)(ypos)/2+3.05;
endypos = (double)(ypos)/2+3.075;
printf("\\psline");
printf("(%.3f,%.3f)",startxpos,startypos);
printf("(%.3f,%.3f)",startxpos,endypos);
printf("%s \tpoint=%.2f\n","%",point);
}
}
return 0;
/*bottom left corner of box */
position = log(start)/log(2);
ypos = (int)position;
startxpos = ((position-(double)ypos))*width;
startypos = (double)(ypos)/2+3.05;
printf("\t(%.2f,%.2f)",startxpos,startypos);
/*top right corner of box*/
position = log(end)/log(2);
ypos = (int)position;
endxpos = ((position-(double)ypos))*width;
endypos = (double)(ypos)/2+3.25;
printf("(%.2f,%.2f) ",endxpos,endypos);
/*text label centered in box*/
printf("(%.2f,",(endxpos - startxpos)/2 + startxpos);
printf("%.2f)\n",(endypos - startypos)/2 + startypos);
}