Back to index

radiance  4R0+20100331
genbeads.c
Go to the documentation of this file.
00001 #ifndef lint
00002 static const char    RCSid[] = "$Id: genbeads.c,v 2.7 2003/11/16 10:29:38 schorsch Exp $";
00003 #endif
00004 /*
00005  *  genbeads.c - generate a string of spheres using Hermite
00006  *            curve specification.
00007  *
00008  *     10/29/85
00009  */
00010 
00011 #include  <stdio.h>
00012 #include <stdlib.h>
00013 #include  <math.h>
00014 
00015 void hermite3(double hp[3], double p0[3], double p1[3],
00016               double r0[3], double r1[3], double t);
00017 void htan3(double ht[3], double p0[3], double p1[3],
00018               double r0[3], double r1[3], double t);
00019 
00020 static void genstring(
00021               char  *mtype,
00022               char  *name,
00023               double  p0[3],
00024               double  p1[3],
00025               double  r0[3],
00026               double  r1[3],
00027               double  rad,
00028               double  inc
00029               )
00030 {
00031        register int  i;
00032        double  v[3];
00033        double  t;
00034        
00035        t = 0.0;
00036        for (i = 0; t <= 1.0; i++) {
00037 
00038               printf("\n%s sphere %s.%d\n", mtype, name, i);
00039               
00040               hermite3(v, p0, p1, r0, r1, t);
00041               
00042               printf("0\n0\n4 %18.12g %18.12g %18.12g %18.12g\n",
00043                                    v[0], v[1], v[2], rad);
00044 
00045               htan3(v, p0, p1, r0, r1, t);
00046               t += inc / sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
00047        }
00048 }
00049 
00050 int main(int  argc, char  **argv)
00051 {
00052        double  p0[3], p1[3], r0[3], r1[3];
00053        double  rad, inc;
00054        char  *mtype;        /* material type */
00055        char  *name;         /* name */
00056        
00057        if (argc != 17) {
00058               fprintf(stderr, "Usage: %s material name p0 p1 r0 r1 rad inc\n",
00059                                     argv[0]);
00060               exit(1);
00061        }
00062        mtype = argv[1];
00063        name = argv[2];
00064        p0[0] = atof(argv[3]);
00065        p0[1] = atof(argv[4]);
00066        p0[2] = atof(argv[5]);
00067        p1[0] = atof(argv[6]);
00068        p1[1] = atof(argv[7]);
00069        p1[2] = atof(argv[8]);
00070        r0[0] = atof(argv[9]);
00071        r0[1] = atof(argv[10]);
00072        r0[2] = atof(argv[11]);
00073        r1[0] = atof(argv[12]);
00074        r1[1] = atof(argv[13]);
00075        r1[2] = atof(argv[14]);
00076        rad = atof(argv[15]);
00077        inc = atof(argv[16]);
00078        
00079        genstring(mtype, name, p0, p1, r0, r1, rad, inc);
00080        
00081        return(0);
00082 }
00083