|
| 1 | +#include<stdio.h> |
| 2 | +#include<stdlib.h> |
| 3 | +#include<math.h> |
| 4 | +/* Description: Generate X position for spectrum chart derived from xpos.c |
| 5 | +input: frequency range (default MHz) |
| 6 | +output: position row & col corrected inches |
| 7 | +Arguments: multiplier offset thickness |
| 8 | + |
| 9 | +
|
| 10 | +Usage: |
| 11 | +cat tex/3G-F.txt | ./xpose6 1e6 0.250 0.020 > tex/3Gbands.tex |
| 12 | +cat tex/LTE-F.txt | ./xpose6 1e6 0.270 0.020 > tex/4Gbands.tex |
| 13 | +cat tex/5G-F1.txt | ./xpose6 1e6 0.290 0.020 > tex/5GF1bands.tex |
| 14 | +cat tex/5G-F2.txt | ./xpose6 1e9 0.290 0.020 > tex/5GF2bands.tex |
| 15 | +
|
| 16 | +*/ |
| 17 | + |
| 18 | +int main(int argc, char* argv[] ) { |
| 19 | + double multiplier;// multliper from command line |
| 20 | + double yoffset; //y offset from command line |
| 21 | + double thickness; //y thickness from command line |
| 22 | + double xpos, start, end, startxpos, endxpos, botypos, topypos, startposition,endposition,width; |
| 23 | + int startypos,endypos; |
| 24 | + width=9.8; /*inches*/ |
| 25 | + |
| 26 | + //Multiplier (i.e. 1e6, 1e9, etc). |
| 27 | + if( argc > 1 ) { |
| 28 | + multiplier = atof(argv[1]); |
| 29 | + } else { |
| 30 | + multiplier = 1.0; |
| 31 | + } |
| 32 | + |
| 33 | + //Y offset in inches. |
| 34 | + if( argc > 2 ) { |
| 35 | + yoffset = atof(argv[2]); |
| 36 | + } else { |
| 37 | + yoffset = 0.0; |
| 38 | + } |
| 39 | + |
| 40 | + //Y thickness in inches. |
| 41 | + if( argc > 3 ) { |
| 42 | + thickness = atof(argv[3]); |
| 43 | + } else { |
| 44 | + thickness = 0.100; |
| 45 | + } |
| 46 | + |
| 47 | + while (scanf("%lf %lf", &start, &end) == 2){ |
| 48 | + start = start * multiplier; |
| 49 | + end = end * multiplier; |
| 50 | + |
| 51 | + /*bottom left corner of box */ |
| 52 | + startposition = log(start)/log(2); |
| 53 | + startypos = (int)startposition; |
| 54 | + startxpos = ((startposition-(double)startypos))*width; |
| 55 | + botypos = (double)(startypos)/2+3.00+yoffset; //3.00 is the base |
| 56 | + |
| 57 | + /*top right corner of box*/ |
| 58 | + endposition = log(end)/log(2); |
| 59 | + endypos = (int)endposition; |
| 60 | + endxpos = ((endposition-(double)endypos))*width; |
| 61 | + topypos = (double)(endypos)/2+3.00+yoffset+thickness; //3.25 is the top |
| 62 | + |
| 63 | + if (startxpos<endxpos){ |
| 64 | + printf("\\psframe(%.3f,%.3f)(%.3f,%.3f)\n", startxpos, topypos-thickness, endxpos, topypos); |
| 65 | + }else{ |
| 66 | + printf("\\psframe(%.3f,%.3f)(9.800,%.3f)", startxpos, botypos, botypos+thickness); |
| 67 | + printf("\\psframe(0.000,%.3f)(%.3f,%.3f)\n", topypos-thickness, endxpos, topypos); |
| 68 | + } |
| 69 | + |
| 70 | + /* check for overlap */ |
| 71 | + } |
| 72 | + return 0; |
| 73 | + |
| 74 | +} |
0 commit comments