Back to index

radiance  4R0+20100331
Defines | Functions | Variables
o_cone.c File Reference
#include "standard.h"
#include "octree.h"
#include "object.h"
#include "cone.h"
#include "plocate.h"

Go to the source code of this file.

Defines

#define ROOT3   1.732050808

Functions

static int findcseg (FVECT ep0, FVECT ep1, CONE *co, FVECT p)
int o_cone (OBJREC *o, register CUBE *cu)
static int findcseg (FVECT ep0, FVECT ep1, register CONE *co, FVECT p)

Variables

static const char RCSid [] = "$Id: o_cone.c,v 2.6 2007/11/21 18:51:04 greg Exp $"
double mincusize

Define Documentation

#define ROOT3   1.732050808

Definition at line 16 of file o_cone.c.


Function Documentation

static int findcseg ( FVECT  ep0,
FVECT  ep1,
CONE co,
FVECT  p 
) [static]

Here is the caller graph for this function:

static int findcseg ( FVECT  ep0,
FVECT  ep1,
register CONE co,
FVECT  p 
) [static]

Definition at line 97 of file o_cone.c.

{
       double  d;
       FVECT  v;
       register int  i;
                                   /* find direction from axis to point */
       VSUB(v, p, CO_P0(co));
       d = DOT(v, co->ad);
       for (i = 0; i < 3; i++)
              v[i] -= d*co->ad[i];
       if (normalize(v) == 0.0)
              return(0);
                                   /* find endpoints of segment */
       for (i = 0; i < 3; i++) {
              ep0[i] = CO_R0(co)*v[i] + CO_P0(co)[i];
              ep1[i] = CO_R1(co)*v[i] + CO_P1(co)[i];
       }
       return(1);                  /* return distance from axis */
}

Here is the call graph for this function:

int o_cone ( OBJREC o,
register CUBE cu 
)

Definition at line 38 of file o_cone.c.

{
       CONE  *co;
       FVECT  ep0, ep1;
#ifdef STRICT
       FVECT  cumin, cumax;
       CUBE  cukid;
       register int  j;
#endif
       double  r;
       FVECT  p;
       register int  i;
                                   /* get cone arguments */
       co = getcone(o, 0);
                                   /* get cube center */
       r = cu->cusize * 0.5;
       for (i = 0; i < 3; i++)
              p[i] = cu->cuorg[i] + r;
       r *= ROOT3;                 /* bounding radius for cube */

       if (findcseg(ep0, ep1, co, p)) {
                                   /* check min. distance to cone */
              if (dist2lseg(p, ep0, ep1) > (r+FTINY)*(r+FTINY))
                     return(O_MISS);
#ifdef  STRICT
                                   /* get cube boundaries */
              for (i = 0; i < 3; i++)
                     cumax[i] = (cumin[i] = cu->cuorg[i]) + cu->cusize;
                                   /* closest segment intersects? */
              if (clip(ep0, ep1, cumin, cumax))
                     return(O_HIT);
       }
                                   /* check sub-cubes */
       cukid.cusize = cu->cusize * 0.5;
       if (cukid.cusize < mincusize)
              return(O_HIT);              /* cube too small */
       cukid.cutree = EMPTY;

       for (j = 0; j < 8; j++) {
              for (i = 0; i < 3; i++) {
                     cukid.cuorg[i] = cu->cuorg[i];
                     if (1<<i & j)
                            cukid.cuorg[i] += cukid.cusize;
              }
              if (o_cone(o, &cukid))
                     return(O_HIT);       /* sub-cube intersects */
       }
       return(O_MISS);                    /* no intersection */
#else
       }
       return(O_HIT);                     /* assume intersection */
#endif
}

Here is the call graph for this function:


Variable Documentation

double mincusize

Definition at line 30 of file obj2mesh.c.

const char RCSid[] = "$Id: o_cone.c,v 2.6 2007/11/21 18:51:04 greg Exp $" [static]

Definition at line 2 of file o_cone.c.