home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 25
/
CD_ASCQ_25_1095.iso
/
dos
/
graphic
/
link
/
link5.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-07-12
|
1KB
|
49 lines
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
void main(int argc, char **argv){
if(argc==4){
int
i, /* loop counter */
iS; /* the number of spheres */
float
fL, /* length of link */
fW, /* width of link */
fP, /* Pi */
fPh, /* Phi */
fTh, /* Theta */
fX, /* X coord */
fY, /* Y coord */
fZ, /* Z coord */
fTZ; /* temp Z coord */
fL=atof(argv[1])/2;
fW=atof(argv[2])/2;
iS=floor(atoi(argv[3])/2);
fP=3.141592654;
printf("R = %f\n\n",fL/10);
for(i=0;i<iS;i++){
fPh=fP*i/iS;
fTh=(1-cos(fPh))*(fP/4);
fX=fW*cos(fTh)*sin(fPh);
fY=fW*sin(fTh)*sin(fPh);
fTZ=cos(fPh);
/* fZ=fL*sqrt(fabs(fTZ))*fTZ/fabs(fTZ);*/
/* fZ=fL*fTZ*(1+cos(fP*fTZ/2)*2/3);*/
fZ=fL*fTZ*(1+fTZ*(sin(fP*fTZ))*1/8);
printf("%f, %f, %f, R\n",fX,fY,fZ);
}
for(i=0;i<iS;i++){
fPh=fP*i/iS;
fTh=-(1-cos(fPh))*(fP/4)-fP/2;
fX=fW*cos(fTh)*sin(fPh);
fY=fW*sin(fTh)*sin(fPh);
fTZ=cos(fPh);
/* fZ=fL*(-sqrt(fabs(fTZ))*fTZ/fabs(fTZ));*/
/* fZ=-fL*fTZ*(1+cos(fP*fTZ/2)*2/3);*/
fZ=-fL*fTZ*(1+fTZ*(sin(fP*fTZ))*1/8);
printf("%f, %f, %f, R\n",fX,fY,fZ);
}
}
else printf("Usage: link(length) (width) (spheres) > (filename)\n");
}