Back to index

radiance  4R0+20100331
Defines | Typedefs | Functions
fvect.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define RREAL   double
#define FTINY   (1e-6)
#define FHUGE   (1e10)
#define VCOPY(v1, v2)   ((v1)[0]=(v2)[0],(v1)[1]=(v2)[1],(v1)[2]=(v2)[2])
#define DOT(v1, v2)   ((v1)[0]*(v2)[0]+(v1)[1]*(v2)[1]+(v1)[2]*(v2)[2])
#define VLEN(v)   sqrt(DOT(v,v))
#define VADD(vr, v1, v2)
#define VSUB(vr, v1, v2)
#define VSUM(vr, v1, v2, f)
#define VCROSS(vr, v1, v2)

Typedefs

typedef RREAL FVECT [3]

Functions

double fdot (FVECT v1, FVECT v2)
double dist2 (FVECT v1, FVECT v2)
double dist2line (FVECT p, FVECT ep1, FVECT ep2)
double dist2lseg (FVECT p, FVECT ep1, FVECT ep2)
void fcross (FVECT vres, FVECT v1, FVECT v2)
void fvsum (FVECT vres, FVECT v0, FVECT v1, double f)
double normalize (FVECT v)
int closestapproach (RREAL t[2], FVECT rorg0, FVECT rdir0, FVECT rorg1, FVECT rdir1)
void spinvector (FVECT vres, FVECT vorig, FVECT vnorm, double theta)

Define Documentation

#define DOT (   v1,
  v2 
)    ((v1)[0]*(v2)[0]+(v1)[1]*(v2)[1]+(v1)[2]*(v2)[2])

Definition at line 23 of file fvect.h.

#define FHUGE   (1e10)

Definition at line 18 of file fvect.h.

#define FTINY   (1e-6)

Definition at line 16 of file fvect.h.

#define RREAL   double

Definition at line 15 of file fvect.h.

#define VADD (   vr,
  v1,
  v2 
)
Value:
((vr)[0]=(v1)[0]+(v2)[0], \
                            (vr)[1]=(v1)[1]+(v2)[1], \
                            (vr)[2]=(v1)[2]+(v2)[2])

Definition at line 25 of file fvect.h.

#define VCOPY (   v1,
  v2 
)    ((v1)[0]=(v2)[0],(v1)[1]=(v2)[1],(v1)[2]=(v2)[2])

Definition at line 22 of file fvect.h.

#define VCROSS (   vr,
  v1,
  v2 
)
Value:
((vr)[0]=(v1)[1]*(v2)[2]-(v1)[2]*(v2)[1], \
                     (vr)[1]=(v1)[2]*(v2)[0]-(v1)[0]*(v2)[2], \
                     (vr)[2]=(v1)[0]*(v2)[1]-(v1)[1]*(v2)[0])

Definition at line 34 of file fvect.h.

#define VLEN (   v)    sqrt(DOT(v,v))

Definition at line 24 of file fvect.h.

#define VSUB (   vr,
  v1,
  v2 
)
Value:
((vr)[0]=(v1)[0]-(v2)[0], \
                            (vr)[1]=(v1)[1]-(v2)[1], \
                            (vr)[2]=(v1)[2]-(v2)[2])

Definition at line 28 of file fvect.h.

#define VSUM (   vr,
  v1,
  v2,
 
)
Value:
((vr)[0]=(v1)[0]+(f)*(v2)[0], \
                            (vr)[1]=(v1)[1]+(f)*(v2)[1], \
                            (vr)[2]=(v1)[2]+(f)*(v2)[2])

Definition at line 31 of file fvect.h.


Typedef Documentation

typedef RREAL FVECT[3]

Definition at line 20 of file fvect.h.


Function Documentation

int closestapproach ( RREAL  t[2],
FVECT  rorg0,
FVECT  rdir0,
FVECT  rorg1,
FVECT  rdir1 
)

Definition at line 136 of file fvect.c.

{
       double dotprod = DOT(rdir0, rdir1);
       double denom = 1. - dotprod*dotprod;
       double o1o2_d1;
       FVECT  o0o1;

       if (denom <= FTINY) {              /* check if lines are parallel */
              t[0] = t[1] = 0.0;
              return(0);
       }
       VSUB(o0o1, rorg0, rorg1);
       o1o2_d1 = DOT(o0o1, rdir1);
       t[0] = (o1o2_d1*dotprod - DOT(o0o1,rdir0)) / denom;
       t[1] = o1o2_d1 + t[0]*dotprod;
       return(1);
}
double dist2 ( FVECT  v1,
FVECT  v2 
)

Definition at line 25 of file fvect.c.

{
       FVECT  delta;

       delta[0] = p2[0] - p1[0];
       delta[1] = p2[1] - p1[1];
       delta[2] = p2[2] - p1[2];

       return(DOT(delta, delta));
}

Here is the caller graph for this function:

double dist2line ( FVECT  p,
FVECT  ep1,
FVECT  ep2 
)

Definition at line 41 of file fvect.c.

{
       double  d, d1, d2;

       d = dist2(ep1, ep2);
       d1 = dist2(ep1, p);
       d2 = d + d1 - dist2(ep2, p);

       return(d1 - 0.25*d2*d2/d);
}

Here is the call graph for this function:

Here is the caller graph for this function:

double dist2lseg ( FVECT  p,
FVECT  ep1,
FVECT  ep2 
)

Definition at line 58 of file fvect.c.

{
       double  d, d1, d2;

       d = dist2(ep1, ep2);
       d1 = dist2(ep1, p);
       d2 = dist2(ep2, p);

       if (d2 > d1) {                     /* check if past endpoints */
              if (d2 - d1 > d)
                     return(d1);
       } else {
              if (d1 - d2 > d)
                     return(d2);
       }
       d2 = d + d1 - d2;

       return(d1 - 0.25*d2*d2/d);  /* distance to line */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fcross ( FVECT  vres,
FVECT  v1,
FVECT  v2 
)

Definition at line 84 of file fvect.c.

{
       vres[0] = v1[1]*v2[2] - v1[2]*v2[1];
       vres[1] = v1[2]*v2[0] - v1[0]*v2[2];
       vres[2] = v1[0]*v2[1] - v1[1]*v2[0];
}
double fdot ( FVECT  v1,
FVECT  v2 
)

Definition at line 15 of file fvect.c.

{
       return(DOT(v1,v2));
}

Here is the caller graph for this function:

void fvsum ( FVECT  vres,
FVECT  v0,
FVECT  v1,
double  f 
)

Definition at line 97 of file fvect.c.

{
       vres[0] = v0[0] + f*v1[0];
       vres[1] = v0[1] + f*v1[1];
       vres[2] = v0[2] + f*v1[2];
}

Here is the caller graph for this function:

double normalize ( FVECT  v)

Definition at line 111 of file fvect.c.

{
       double  len, d;
       
       d = DOT(v, v);
       
       if (d == 0.0)
              return(0.0);
       
       if (d <= 1.0+FTINY && d >= 1.0-FTINY)
              len = 0.5 + 0.5*d;   /* first order approximation */
       else
              len = sqrt(d);

       v[0] *= d = 1.0/len;
       v[1] *= d;
       v[2] *= d;

       return(len);
}
void spinvector ( FVECT  vres,
FVECT  vorig,
FVECT  vnorm,
double  theta 
)

Definition at line 162 of file fvect.c.

{
       double  sint, cost, normprod;
       FVECT  vperp;
       int  i;
       
       if (theta == 0.0) {
              if (vres != vorig)
                     VCOPY(vres, vorig);
              return;
       }
       cost = cos(theta);
       sint = sin(theta);
       normprod = DOT(vorig, vnorm)*(1.-cost);
       fcross(vperp, vnorm, vorig);
       for (i = 0; i < 3; i++)
              vres[i] = vorig[i]*cost + vnorm[i]*normprod + vperp[i]*sint;
}

Here is the call graph for this function:

Here is the caller graph for this function: