Back to index

radiance  4R0+20100331
Defines | Functions | Variables
tcos.c File Reference
#include "copyright.h"
#include <math.h>
#include "rtmath.h"

Go to the source code of this file.

Defines

#define NCOSENTRY   256
#define PI   3.14159265358979323846

Functions

double tcos (double x)

Variables

static const char RCSid [] = "$Id: tcos.c,v 3.4 2003/07/17 09:21:29 schorsch Exp $"

Define Documentation

#define NCOSENTRY   256

Definition at line 22 of file tcos.c.

#define PI   3.14159265358979323846

Definition at line 28 of file tcos.c.


Function Documentation

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:


Variable Documentation

const char RCSid[] = "$Id: tcos.c,v 3.4 2003/07/17 09:21:29 schorsch Exp $" [static]

Definition at line 2 of file tcos.c.