home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
gdead.berkeley.edu
/
gdead.berkeley.edu.tar
/
gdead.berkeley.edu
/
pub
/
cad-tools
/
ciftomann.tar
/
pggen_dir
/
misc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-01-28
|
2KB
|
107 lines
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589793
dir_to_angle(x_int, y_int)
int x_int;
int y_int;
{
double value;
double arg;
int degree_value;
if ( y_int == 0 ) {
return(0);
}
if ( x_int == 0 ) {
return(900);
}
arg = ( (double) y_int)/ ( (double) x_int);
value = atan(arg);
/* convert to an integer number of tenths of degrees */
degree_value = (int) (1800*value/PI);
if (degree_value < 0) {
degree_value += 1800;
}
return(degree_value);
}
extern int command_number;
error(str)
char *str;
{
fprintf(stderr,"error at command %d : %s\n",command_number,str);
exit(1);
}
extern FILE *infile;
flush_to_semi()
{
register char c;
while ( (c = getc(infile)) != EOF ) {
if ( c == ';' ) {
return;
}
}
error("Unexpected end of file");
}
flush_comment()
{
int level = 1;
char c;
while ( (c = getc(infile)) != EOF ) {
if ( c == '(' ) {
level++;
} else if ( c== ')' ) {
level--;
}
if ( level <= 0) {
flush_to_semi();
return;
}
}
error("Unexpected end of file");
}
#define min(x,y) ( (x) < (y) ? (x) : (y) )
#define max(x,y) ( (x) > (y) ? (x) : (y) )
extern left, right, bottom, top;
int first_bb = 1;
/* compute a bounding box for the masks */
update_bb(l,w,x,y)
int l,w,x,y;
{
if ( first_bb ) {
left = x - l/2;
right = x + l/2;
bottom = y - w/2;
top = y + w/2;
first_bb = 0;
} else {
left = min(left, x - l/2);
right = max(right, x + l/2);
bottom = min(bottom, y - w/2);
top = max(top, y + w/2);
}
}