steric_1.11
|
Makefile,
Makefile.sgi,
README.steric,
contplot,
craig.c,
craig.h,
crystal.c,
crystal.h,
integrat.c,
integrat.h,
leach.c,
leach.h,
long_steric,
makeit,
mapcont,
mapcont.c,
mapprof,
mapprof.c,
profplot,
proja.c,
proja.h,
ryan.c,
ryan.h,
ryan_perm.c,
ryan_perm.h,
ryan_quad.c,
ryan_quad.h,
steraid.c,
steraid.h,
stercalc.c,
stercalc.h,
stercomm.c,
stercomm.h,
sterdefn.h,
stererr.h,
sterfile.c,
sterfile.h,
stergrap.c,
stergrap.h,
stergrp.c,
stergrp.h,
steric,
steric.TeX,
steric.err,
steric.grp,
steric.hlp,
steric.ini,
steric.par,
stermain.c,
stermem.c,
stermem.h,
sterover.c,
sterover.h,
sterplot,
stertext.c,
stertext.h,
test.bgf,
test.inp,
vectors.c,
vectors.h,
|
|
|
/* program to translate cylindrical coords to cartesian coords */
#include
#include
#include
#define CART 1 /* convert to true cartesian */
#define PERS 2 /* use perspective mode as output by steric */
#define ROTA 0.0 /* default rotation about phi to perform */
#define STEP 50 /* default number of steps in angular array */
#define BIG 1000.0
#ifndef PI
#define PI 3.14159265358979323846
#endif
#ifndef PI_2
#define PI_2 1.57079632679489661923
#endif
int main(int argc, char *argv[])
{
char line[255];
char card[100];
char field[100];
char type='c';
double x,y,z;
double theta,phi;
int step=STEP;
double rotation=ROTA;
char mode=CART;
int i;
for(i=1;i2*PI) rotation=ROTA;
do
{
if(fgets(line,254,stdin)==NULL) break;
if(line[0]=='q') break;
if((strncmp(line,"#STERIC",7)==0)&&(sscanf(line,"%s%s",card,field)==2))
{
sscanf(field,"%c",&type);
if((type=='o')||(type=='r')||(type=='g')||(type=='n')||(type=='s'))
type='s';
else type='c';
}
if((line[0]!='#')&&(strlen(line)>4))
{
if((sscanf(line,"%lf%lf",&z,&theta)==2)&&(fabs(theta)>0.0001))
{
if(type=='s') theta=(acos( 1-(theta/(2*PI)) ));
else theta/=2.0;
phi=rotation;
for(i=0;i<=step;i++)
{
phi+=2*PI/step;
if(mode!=CART)
{
x=sin(theta)*cos(phi);
y=sin(theta)*sin(phi);
if((fabs(x)>BIG)||(fabs(y)>BIG))
fprintf(stderr,"# PERS ERROR: phi=%f theta=%f x=%f y=%f z=%f\n"
,phi,theta,x,y,z);
}
else
{
x=z*tan(theta)*cos(phi);
y=z*tan(theta)*sin(phi);
if((fabs(x)>BIG)||(fabs(y)>BIG))
fprintf(stderr,"# CART ERROR: phi=%f theta=%f x=%f y=%f z=%f\n"
,phi,theta,x,y,z);
}
fprintf(stdout,"%10.6f %10.6f %10.6f\n",x,y,z);
}
}
line[0]=0;
}
fprintf(stdout,"%s\n",line);
} while(!feof(stdin));
return(1);
}
|