Back to index

radiance  4R0+20100331
Classes | Defines | Functions
rtmath.h File Reference
#include <math.h>
#include "tiff.h"
#include "mat4.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  XF
struct  FULLXF

Defines

#define PI   3.14159265358979323846
#define tsin(x)   tcos((x)-(PI/2.))
#define ttan(x)   (tsin(x)/tcos(x))

Functions

double tcos (double x)
int xf (XF *ret, int ac, char *av[])
int invxf (XF *ret, int ac, char *av[])
int fullxf (FULLXF *fx, int ac, char *av[])
int quadratic (double *r, double a, double b, double c)
int32 encodedir (FVECT dv)
void decodedir (FVECT dv, int32 dc)
double dir2diff (int32 dc1, int32 dc2)
double fdir2diff (int32 dc1, FVECT v2)

Class Documentation

struct XF

Definition at line 19 of file rtmath.h.

Class Members
RREAL sca
MAT4 xfm
struct FULLXF

Definition at line 24 of file rtmath.h.

Collaboration diagram for FULLXF:
Class Members
XF b
XF f

Define Documentation

#define PI   3.14159265358979323846

Definition at line 33 of file rtmath.h.

#define tsin (   x)    tcos((x)-(PI/2.))

Definition at line 43 of file rtmath.h.

#define ttan (   x)    (tsin(x)/tcos(x))

Definition at line 44 of file rtmath.h.


Function Documentation

void decodedir ( FVECT  dv,
int32  dc 
)

Definition at line 56 of file dircode.c.

{
       double d1, d2, der;

       if (!dc) {           /* special code for zero normal */
              dv[0] = dv[1] = dv[2] = 0.;
              return;
       }
       d1 = ((dc>>F1SFT & FMASK)+.5)*(1./DCSCALE);
       d2 = ((dc>>F2SFT & FMASK)+.5)*(1./DCSCALE);
       der = sqrt(1. - d1*d1 - d2*d2);
       if (dc & F1X) {
              dv[0] = d1;
              if (dc & F2Z) { dv[1] = der; dv[2] = d2; }
              else { dv[1] = d2; dv[2] = der; }
       } else {
              dv[1] = d1;
              if (dc & F2Z) { dv[0] = der; dv[2] = d2; }
              else { dv[0] = d2; dv[2] = der; }
       }
       if (dc & FXNEG) dv[0] = -dv[0];
       if (dc & FYNEG) dv[1] = -dv[1];
       if (dc & FZNEG) dv[2] = -dv[2];
}

Here is the caller graph for this function:

double dir2diff ( int32  dc1,
int32  dc2 
)

Definition at line 85 of file dircode.c.

{
       FVECT  v1, v2;

       decodedir(v1, dc1);
       decodedir(v2, dc2);

       return(2. - 2.*DOT(v1,v2));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int32 encodedir ( FVECT  dv)

Definition at line 23 of file dircode.c.

{
       register int32       dc = 0;
       int    cd[3], cm;
       register int  i;

       for (i = 0; i < 3; i++)
              if (dv[i] < 0.) {
                     cd[i] = (int)(dv[i] * -DCSCALE);
                     dc |= FXNEG<<i;
              } else
                     cd[i] = (int)(dv[i] * DCSCALE);
       if (!(cd[0] | cd[1] | cd[2]))
              return(0);           /* zero normal */
       if (cd[0] <= cd[1]) {
              dc |= F1X | cd[0] << F1SFT;
              cm = cd[1];
       } else {
              dc |= cd[1] << F1SFT;
              cm = cd[0];
       }
       if (cd[2] <= cm)
              dc |= F2Z | cd[2] << F2SFT;
       else
              dc |= cm << F2SFT;
       if (!dc)      /* don't generate 0 code normally */
              dc = F1X;
       return(dc);
}

Here is the caller graph for this function:

double fdir2diff ( int32  dc1,
FVECT  v2 
)

Definition at line 98 of file dircode.c.

{
       FVECT  v1;

       decodedir(v1, dc1);

       return(2. - 2.*DOT(v1,v2));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int fullxf ( FULLXF fx,
int  ac,
char *  av[] 
)

Here is the caller graph for this function:

int invxf ( XF ret,
int  ac,
char *  av[] 
)

Here is the caller graph for this function:

int quadratic ( double *  r,
double  a,
double  b,
double  c 
)

Definition at line 19 of file zeroes.c.

{
       double  disc;
       int  first;

       if (a < -FTINY)
              first = 1;
       else if (a > FTINY)
              first = 0;
       else if (fabs(b) > FTINY) { /* solve linearly */
              r[0] = -c/b;
              return(1);
       } else
              return(0);           /* equation is c == 0 ! */
              
       b *= 0.5;                   /* simplifies formula */
       
       disc = b*b - a*c;           /* discriminant */

       if (disc < -FTINY*FTINY)    /* no real roots */
              return(0);

       if (disc <= FTINY*FTINY) {  /* double root */
              r[0] = -b/a;
              return(1);
       }
       
       disc = sqrt(disc);

       r[first] = (-b - disc)/a;
       r[1-first] = (-b + disc)/a;

       return(2);
}

Here is the caller graph for this function:

double tcos ( double  x)

Definition at line 33 of file tcos.c.

{
       static double costab[NCOSENTRY+1];
       register int  i;

       if (costab[0] < 0.5)        /* initialize table */
              for (i = 0; i <= NCOSENTRY; i++)
                     costab[i] = cos((PI/2./NCOSENTRY)*i);
                                   /* normalize angle */
       if (x < 0.)
              x = -x;
       i = (NCOSENTRY*2./PI) * x  +  0.5;
       if (i >= 4*NCOSENTRY)
              i %= 4*NCOSENTRY;
       switch (i / NCOSENTRY) {
       case 0:
              return(costab[i]);
       case 1:
              return(-costab[(2*NCOSENTRY)-i]);
       case 2:
              return(-costab[i-(2*NCOSENTRY)]);
       case 3:
              return(costab[(4*NCOSENTRY)-i]);
       }
       return(0.);          /* should never be reached */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int xf ( XF ret,
int  ac,
char *  av[] 
)

Here is the caller graph for this function: