#include #include #include void draw_tic(double,double,double); void draw_num(double,double,double,double,int,char); void draw_cd_scale(double,double); void draw_ab_scale(double,double); void draw_sin_scale(double,double); void draw_cos_scale(double,double); void draw_exponent_scale(double,double); void draw_k_scale(double,double); void draw_cd_nums(double,double); void draw_ab_nums(double,double); void draw_sin_nums(double,double); void draw_cos_nums(double,double); void draw_exponent_nums(double,double); void draw_k_nums(double,double); int main(int argc, char* argv[]) { printf("\n"); printf("\n"); printf("\n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); draw_exponent_nums(21,5); draw_cd_nums(48,-5); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); draw_cd_nums(48,5); draw_sin_nums(75,-5); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); draw_k_nums(21,5); draw_ab_nums(48,-5); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); draw_ab_nums(48,5); draw_cos_nums(75,-5); printf(" \n"); printf(" \n"); printf("\n"); return 0; } void draw_tic(double r, double w, double t) { double x1 = r*sin(t); double y1 = -r*cos(t); double x2 = (r+w)*sin(t); double y2 = -(r+w)*cos(t); printf("M%f %fL%f %f",x1,y1,x2,y2); } void draw_num(double r, double w, double t, double num, int sizeflag, char type) { double x; double y; if( sizeflag ) { if( w > 0 ) { x = (r+w+w/fabs(w)*1)*sin(t); y = -(r+w+w/fabs(w)*1)*cos(t); } else { x = (r+w+w/fabs(w)*6)*sin(t); y = -(r+w+w/fabs(w)*6)*cos(t); } } else { if( w > 0 ) { x = (r+w+w/fabs(w)*1)*sin(t); y = -(r+w+w/fabs(w)*1)*cos(t); } else { x = (r+w+w/fabs(w)*4)*sin(t); y = -(r+w+w/fabs(w)*4)*cos(t); } } printf(" \n"); if( type == 'f' ) printf(" %.2f\n",num); else if( type == 'e' ) printf(" e\n"); else if( type == 'p' ) printf(" p\n"); else printf(" %i\n",(int)num); printf(" \n"); } void draw_cd_scale(double r, double w) { draw_tic(r,w,0); int i,j; double t; for( i=1; i<100; i++ ) { t = 2*M_PI*log((double)i/100.0+1.0)/log(10.0); if( i % 10 == 0 ) { draw_tic(r,w,t); } else if ( i % 5 == 0 ) { draw_tic(r,2*w/3,t); } else { draw_tic(r,w/3,t); } } for( j=2; j<4; j++ ) { draw_tic(r,w,2*M_PI*log((double)j)/log(10.0)); for( i=1; i<50; i++ ) { t = 2*M_PI*log((double)i/50.0+(double)j)/log(10.0); if( i % 25 == 0 ) { draw_tic(r,w,t); } else if ( i % 5 == 0 ) { draw_tic(r,2*w/3,t); } else { draw_tic(r,w/3,t); } } } for( j=4; j<10; j++ ) { draw_tic(r,w,2*M_PI*log((double)j)/log(10.0)); for( i=1; i<20; i++ ) { t = 2*M_PI*log((double)i/20.0+(double)j)/log(10.0); if( i % 10 == 0 ) { draw_tic(r,w,t); } else if ( i % 2 == 0 ) { draw_tic(r,2*w/3,t); } else { draw_tic(r,w/3,t); } } } t = 2*M_PI*log(exp(1.0))/log(10.0); draw_tic(r,w,t); t = 2*M_PI*log(M_PI)/log(10.0); draw_tic(r,w,t); } void draw_ab_scale(double r,double w) { int i,j; double t1, t2; for( j=1; j<2; j++ ) { draw_tic(r,w,-M_PI*log((double)j)/log(10)); draw_tic(r,w,-M_PI*log((double)j)/log(10)+M_PI); for( i=1; i<50; i++ ) { t1 = M_PI*log((double)i/50.0+(double)j)/log(10.0); t2 = t1 + M_PI; if( i % 25 == 0 ) { draw_tic(r,w,-t1); draw_tic(r,w,-t2); } else if ( i % 5 == 0 ) { draw_tic(r,2*w/3,-t1); draw_tic(r,2*w/3,-t2); } else { draw_tic(r,w/3,-t1); draw_tic(r,w/3,-t2); } } } for( j=2; j<6; j++ ) { draw_tic(r,w,-M_PI*log((double)j)/log(10.0)); draw_tic(r,w,-M_PI*log((double)j)/log(10.0)+M_PI); for( i=1; i<20; i++ ) { t1 = M_PI*log((double)i/20.0+(double)j)/log(10.0); t2 = t1 + M_PI; if( i % 10 == 0 ) { draw_tic(r,w,-t1); draw_tic(r,w,-t2); } else if ( i % 2 == 0 ) { draw_tic(r,2*w/3,-t1); draw_tic(r,2*w/3,-t2); } else { draw_tic(r,w/3,-t1); draw_tic(r,w/3,-t2); } } } for( j=6; j<10; j++ ) { draw_tic(r,w,-M_PI*log((double)j)/log(10.0)); draw_tic(r,w,-M_PI*log((double)j)/log(10.0)+M_PI); for( i=1; i<10; i++ ) { t1 = M_PI*log((double)i/10.0+(double)j)/log(10.0); t2 = t1+M_PI; if( i % 5 == 0 ) { draw_tic(r,w,-t1); draw_tic(r,w,-t2); } else { draw_tic(r,2*w/3,-t1); draw_tic(r,2*w/3,-t2); } } } } void draw_sin_scale(double r, double w) { int j; double t, i; for( i=0.1; i<0.24; i+=0.02 ) { for( j=1; j<20 && i+j*0.001 < 0.249999; j++ ) { t = 2*M_PI*log(10.0*sin(i+j*0.001))/log(10.0); if( j%10 == 0 ) draw_tic(r,w,t); else if( j%5 == 0 ) draw_tic(r,2*w/3,t); else draw_tic(r,w/3,t); } t = 2*M_PI*log(10.0*sin(i))/log(10.0); draw_tic(r,w,t); } for( i=0.25; i<0.49999; i+=0.05 ) { for( j=1; j<25; j++ ) { t = 2*M_PI*log(10.0*sin(i+j*0.002))/log(10.0); if( j%5 == 0 ) draw_tic(r,2*w/3,t); else draw_tic(r,w/3,t); } t = 2*M_PI*log(10.0*sin(i))/log(10.0); draw_tic(r,w,t); } for( i=0.5; i<0.89999; i+=0.1 ) { for( j=1; j<20; j++ ) { t = 2*M_PI*log(10.0*sin(i+j*0.005))/log(10.0); if( j%10 == 0 ) draw_tic(r,w,t); else if( j%2 == 0 ) draw_tic(r,2*w/3,t); else draw_tic(r,w/3,t); } t = 2*M_PI*log(10.0*sin(i))/log(10.0); draw_tic(r,w,t); } for( i=0.9; i<1.29999; i+=0.2 ) { for( j=1; j<20; j++ ) { t = 2*M_PI*log(10.0*sin(i+j*0.01))/log(10.0); if( j%10 == 0 ) draw_tic(r,w,t); if( j%5 == 0 ) draw_tic(r,2*w/3,t); else draw_tic(r,w/3,t); } t = 2*M_PI*log(10.0*sin(i))/log(10.0); draw_tic(r,w,t); } for( i=1.3; i<1.49999; i+=0.1 ) { for( j=1; j<4; j++ ) { t = 2*M_PI*log(10.0*sin(i+j*0.025))/log(10.0); if( j%2 == 0 ) draw_tic(r,2*w/3,t); else draw_tic(r,w/3,t); } t = 2*M_PI*log(10.0*sin(i))/log(10.0); draw_tic(r,w,t); } } void draw_exponent_scale(double r, double w) { int i, j; double t; for( i=0; i<10; i++ ) { for( j=1; j<10; j++ ) { t = 2*M_PI*log(pow(10.0,i*0.1+j*0.01))/log(10.0); if( j%5 == 0 ) draw_tic(r,w*0.75,t); else draw_tic(r,w*0.5,t); } t = 2*M_PI*log(pow(10.0,i*0.1))/log(10.0); draw_tic(r,w,t); } } void draw_cos_scale(double r, double w) { int j; double t, i; t = 2*M_PI*log(10.0*cos(0))/log(10.0); draw_tic(r,w,-t); for( i=0.1; i<0.3; i+=0.1 ) { for( j=1; j<4; j++ ) { t = 2*M_PI*log(10.0*cos(i+j*0.025))/log(10.0); if( j%2 == 0 ) draw_tic(r,2*w/3,-t); else draw_tic(r,w/3,-t); } t = 2*M_PI*log(10.0*cos(i))/log(10.0); draw_tic(r,w,-t); } for( i=0.3; i<0.6; i+=0.1 ) { for( j=1; j<10; j++ ) { t = 2*M_PI*log(10.0*cos(i+j*0.01))/log(10.0); if( j%5 == 0 ) draw_tic(r,2*w/3,-t); else draw_tic(r,w/3,-t); } t = 2*M_PI*log(10.0*cos(i))/log(10.0); draw_tic(r,w,-t); } for( i=0.6; i<1.09999; i+=0.1 ) { for( j=1; j<20; j++ ) { t = 2*M_PI*log(10.0*cos(i+j*0.005))/log(10.0); if( j%10 == 0 ) draw_tic(r,w,-t); else if( j%5 == 0 ) draw_tic(r,2*w/3,-t); else draw_tic(r,w/3,-t); } t = 2*M_PI*log(10.0*cos(i))/log(10.0); draw_tic(r,w,-t); } for( i=1.1; i<1.29999; i+=0.05 ) { for( j=1; j<25; j++ ) { t = 2*M_PI*log(10.0*cos(i+j*0.002))/log(10.0); if( j%5 == 0 ) draw_tic(r,2*w/3,-t); else draw_tic(r,w/3,-t); } t = 2*M_PI*log(10.0*cos(i))/log(10.0); draw_tic(r,w,-t); } for( i=1.3; i<1.439999; i+=0.02 ) { for( j=1; j<20; j++ ) { t = 2*M_PI*log(10.0*cos(i+j*0.001))/log(10.0); if( j%10 == 0 ) draw_tic(r,w,-t); else if( j%5 == 0 ) draw_tic(r,2*w/3,-t); else draw_tic(r,w/3,-t); } t = 2*M_PI*log(10.0*cos(i))/log(10.0); draw_tic(r,w,-t); } for( i=1.44; i<1.469999; i+=0.01 ) { for( j=1; j<20; j++ ) { t = 2*M_PI*log(10.0*cos(i+j*0.0005))/log(10.0); if( j%10 == 0 ) draw_tic(r,w,-t); else if( j%2 == 0 ) draw_tic(r,2*w/3,-t); else draw_tic(r,w/3,-t); } t = 2*M_PI*log(10.0*cos(i))/log(10.0); draw_tic(r,w,-t); } } void draw_k_scale(double r,double w) { int i,j; double t; for( i=1; i<3; i++ ) { for( j=1; j<10; j++ ) { t = 2*M_PI/3*log((double)i+j*0.1)/log(10); if( j%5 == 0 ) { draw_tic(r,2*w/3,-t); draw_tic(r,2*w/3,-t-2*M_PI/3); draw_tic(r,2*w/3,-t-4*M_PI/3); } else { draw_tic(r,w/3,-t); draw_tic(r,w/3,-t-2*M_PI/3); draw_tic(r,w/3,-t-4*M_PI/3); } } t = 2*M_PI/3*log((double)i)/log(10); draw_tic(r,w,-t); draw_tic(r,w,-t-2*M_PI/3); draw_tic(r,w,-t-4*M_PI/3); } for( i=3; i<7; i++ ) { for( j=1; j<4; j++ ) { t = 2*M_PI/3*log((double)i+j*0.25)/log(10); if( j%2 == 0 ) { draw_tic(r,2*w/3,-t); draw_tic(r,2*w/3,-t-2*M_PI/3); draw_tic(r,2*w/3,-t-4*M_PI/3); } else { draw_tic(r,w/3,-t); draw_tic(r,w/3,-t-2*M_PI/3); draw_tic(r,w/3,-t-4*M_PI/3); } } t = 2*M_PI/3*log((double)i)/log(10); draw_tic(r,w,-t); draw_tic(r,w,-t-2*M_PI/3); draw_tic(r,w,-t-4*M_PI/3); } for( i=7; i<10; i++ ) { for( j=1; j<2; j++ ) { t = 2*M_PI/3*log((double)i+j*0.5)/log(10); draw_tic(r,2*w/3,-t); draw_tic(r,2*w/3,-t-2*M_PI/3); draw_tic(r,2*w/3,-t-4*M_PI/3); } t = 2*M_PI/3*log((double)i)/log(10); draw_tic(r,w,-t); draw_tic(r,w,-t-2*M_PI/3); draw_tic(r,w,-t-4*M_PI/3); } } void draw_cd_nums(double r, double w) { draw_num(r,w,0,1,1,'i'); int i,j; double t; for( i=1; i<100; i++ ) { t = 2*M_PI*log((double)i/100.0+1.0)/log(10.0); if( i % 10 == 0 ) draw_num(r,w,t,i/10,0,'i'); } for( j=2; j<4; j++ ) { draw_num(r,w,2*M_PI*log((double)j)/log(10.0),j,1,'i'); } for( j=4; j<10; j++ ) { draw_num(r,w,2*M_PI*log((double)j)/log(10.0),j,1,'i'); } t = 2*M_PI*log(exp(1.0))/log(10.0); draw_num(r,w,t,0.0,1,'e'); t = 2*M_PI*log(M_PI)/log(10.0); draw_num(r,w,t,0.0,1,'p'); } void draw_ab_nums(double r,double w) { int i,j; double t1, t2; for( j=1; j<2; j++ ) { draw_num(r,w,-M_PI*log((double)j)/log(10),j,1,'i'); draw_num(r,w,-M_PI*log((double)j)/log(10)+M_PI,j,1,'i'); } for( j=2; j<6; j++ ) { draw_num(r,w,-M_PI*log((double)j)/log(10.0),j,1,'i'); draw_num(r,w,-M_PI*log((double)j)/log(10.0)+M_PI,j,1,'i'); } for( j=6; j<10; j++ ) { draw_num(r,w,-M_PI*log((double)j)/log(10.0),j,1,'i'); draw_num(r,w,-M_PI*log((double)j)/log(10.0)+M_PI,j,1,'i'); } } void draw_sin_nums(double r, double w) { int j; double t, i; for( i=0.1; i<0.24; i+=0.02 ) { t = 2*M_PI*log(10.0*sin(i))/log(10.0); draw_num(r,w,t,i,0,'f'); } for( i=0.25; i<0.49999; i+=0.05 ) { t = 2*M_PI*log(10.0*sin(i))/log(10.0); draw_num(r,w,t,i,0,'f'); } for( i=0.5; i<0.89999; i+=0.1 ) { t = 2*M_PI*log(10.0*sin(i))/log(10.0); draw_num(r,w,t,i,0,'f'); } for( i=0.9; i<1.29999; i+=0.2 ) { t = 2*M_PI*log(10.0*sin(i))/log(10.0); draw_num(r,w,t,i,0,'f'); } } void draw_exponent_nums(double r, double w) { int i, j; double t; for( i=0; i<10; i++ ) { t = 2*M_PI*log(pow(10.0,i*0.1))/log(10.0); draw_num(r,w,t,i,0,'i'); } } void draw_cos_nums(double r, double w) { int j; double t, i; t = 2*M_PI*log(10.0*cos(0))/log(10.0); draw_num(r,w,-t,0.0,0,'f'); for( i=0.3; i<0.6; i+=0.1 ) { t = 2*M_PI*log(10.0*cos(i))/log(10.0); draw_num(r,w,-t,i,0,'f'); } for( i=0.6; i<1.09999; i+=0.1 ) { t = 2*M_PI*log(10.0*cos(i))/log(10.0); draw_num(r,w,-t,i,0,'f'); } for( i=1.1; i<1.29999; i+=0.05 ) { t = 2*M_PI*log(10.0*cos(i))/log(10.0); draw_num(r,w,-t,i,0,'f'); } for( i=1.3; i<1.439999; i+=0.02 ) { t = 2*M_PI*log(10.0*cos(i))/log(10.0); draw_num(r,w,-t,i,0,'f'); } for( i=1.44; i<1.469999; i+=0.01 ) { t = 2*M_PI*log(10.0*cos(i))/log(10.0); draw_num(r,w,-t,i,0,'f'); } } void draw_k_nums(double r,double w) { int i,j; double t; for( i=1; i<3; i++ ) { t = 2*M_PI/3*log((double)i)/log(10); draw_num(r,w,-t,i,0,'i'); draw_num(r,w,-t-2*M_PI/3,i,0,'i'); draw_num(r,w,-t-4*M_PI/3,i,0,'i'); } for( i=3; i<7; i++ ) { t = 2*M_PI/3*log((double)i)/log(10); draw_num(r,w,-t,i,0,'i'); draw_num(r,w,-t-2*M_PI/3,i,0,'i'); draw_num(r,w,-t-4*M_PI/3,i,0,'i'); } for( i=7; i<10; i++ ) { t = 2*M_PI/3*log((double)i)/log(10); draw_num(r,w,-t,i,0,'i'); draw_num(r,w,-t-2*M_PI/3,i,0,'i'); draw_num(r,w,-t-4*M_PI/3,i,0,'i'); } }