Back to index

radiance  4R0+20100331
rtmath.h
Go to the documentation of this file.
00001 /* RCSid $Id: rtmath.h,v 3.4 2008/05/31 19:38:36 greg Exp $ */
00002 /*
00003  * Header for Radiance vector and math routines
00004  */
00005 
00006 #ifndef _RAD_RTMATH_H_
00007 #define _RAD_RTMATH_H_
00008 
00009 #include  <math.h>
00010 
00011 #include  "tiff.h"          /* needed for int32, etc. */
00012 #include  "mat4.h"
00013 
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017 
00018                             /* regular transformation */
00019 typedef struct {
00020        MAT4  xfm;                         /* transform matrix */
00021        RREAL  sca;                        /* scalefactor */
00022 }  XF;
00023                             /* complemetary tranformation */
00024 typedef struct {
00025        XF  f;                             /* forward */
00026        XF  b;                             /* backward */
00027 }  FULLXF;
00028 
00029 #ifndef  PI
00030 #ifdef M_PI
00031 #define        PI           ((double)M_PI)
00032 #else
00033 #define        PI           3.14159265358979323846
00034 #endif
00035 #endif
00036 
00037 #ifdef  FASTMATH
00038 #define  tcos               cos
00039 #define  tsin               sin
00040 #define  ttan               tan
00041 #else
00042                                    /* table-based cosine approximation */
00043 #define  tsin(x)            tcos((x)-(PI/2.))
00044 #define  ttan(x)            (tsin(x)/tcos(x))
00045 #endif
00046                                    /* defined in tcos.c */
00047 extern double tcos(double x);
00048                                    /* defined in xf.c */
00049 extern int    xf(XF *ret, int ac, char *av[]);
00050 extern int    invxf(XF *ret, int ac, char *av[]);
00051 extern int    fullxf(FULLXF *fx, int ac, char *av[]);
00052                                    /* defined in zeroes.c */
00053 extern int    quadratic(double *r, double a, double b, double c);
00054                                    /* defined in dircode.c */
00055 extern int32  encodedir(FVECT dv);
00056 extern void   decodedir(FVECT dv, int32 dc);
00057 extern double dir2diff(int32 dc1, int32 dc2);
00058 extern double fdir2diff(int32 dc1, FVECT v2);
00059 
00060 #ifdef __cplusplus
00061 }
00062 #endif
00063 #endif /* _RAD_RTMATH_H_ */
00064