Back to index

radiance  4R0+20100331
Defines | Typedefs | Functions | Variables
genmarble.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "random.h"

Go to the source code of this file.

Defines

#define PI   3.14159265359

Typedefs

typedef double FVECT [3]

Functions

static double bubble ()
static void sphere_cart ()
int main (int argc, char **argv)
static double bubble (FVECT v, FVECT cent, double rad, double bubrad)
static void sphere_cart (FVECT v, double ro, double theta, double phi)

Variables

static const char RCSid [] = "$Id: genmarble.c,v 2.7 2003/11/16 10:29:38 schorsch Exp $"

Define Documentation

#define PI   3.14159265359

Definition at line 18 of file genmarble.c.


Typedef Documentation

typedef double FVECT[3]

Definition at line 20 of file genmarble.c.


Function Documentation

static double bubble ( ) [static]

Here is the caller graph for this function:

static double bubble ( FVECT  v,
FVECT  cent,
double  rad,
double  bubrad 
) [static]

Definition at line 72 of file genmarble.c.

{
       double  r, ro, theta, phi;

       r = frandom()*bubrad;
       ro = sqrt(frandom())*(rad-r);
       theta = frandom()*(2.0*PI);
       phi = frandom()*PI;
       sphere_cart(v, ro, theta, phi);
       v[0] += cent[0]; v[1] += cent[1]; v[2] += cent[2];
       return(r);
}

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 26 of file genmarble.c.

{
       char  *cmtype, *cname;
       FVECT  cent;
       double  rad;
       int  nbubbles, i;
       double  bubrad;
       FVECT  v;
       double  brad;
       
       if (argc != 9) {
              fprintf(stderr,
                     "Usage: %s material name cent rad #bubbles bubrad\n",
                                    argv[0]);
              exit(1);
       }
       cmtype = argv[1];
       cname = argv[2];
       cent[0] = atof(argv[3]);
       cent[1] = atof(argv[4]);
       cent[2] = atof(argv[5]);
       rad = atof(argv[6]);
       nbubbles = atoi(argv[7]);
       bubrad = atof(argv[8]);

       if (bubrad >= rad) {
              fprintf(stderr, "%s: bubbles too big for marble\n", argv[0]);
              exit(1);
       }

       printf("\n%s sphere %s\n", cmtype, cname);
       printf("0\n0\n4 %f %f %f %f\n", cent[0], cent[1], cent[2], rad);

       for (i = 0; i < nbubbles; i++) {
              brad = bubble(v, cent, rad, bubrad);
              printf("\n%s bubble %s.%d\n", cmtype, cname, i);
              printf("0\n0\n4 %f %f %f %f\n", v[0], v[1], v[2], brad);
       }
       
       return(0);
}

Here is the call graph for this function:

static void sphere_cart ( ) [static]

Here is the caller graph for this function:

static void sphere_cart ( FVECT  v,
double  ro,
double  theta,
double  phi 
) [static]

Definition at line 89 of file genmarble.c.

{
       double  d;
       
       d = sin(phi);
       v[0] = ro*d*cos(theta);
       v[1] = ro*d*sin(theta);
       v[2] = ro*cos(phi);
}

Here is the call graph for this function:


Variable Documentation

const char RCSid[] = "$Id: genmarble.c,v 2.7 2003/11/16 10:29:38 schorsch Exp $" [static]

Definition at line 2 of file genmarble.c.