| 1 |
greg |
3.14 |
/* RCSid $Id: rtmath.h,v 3.13 2021/12/03 16:50:05 greg Exp $ */
|
| 2 |
greg |
3.1 |
/*
|
| 3 |
|
|
* Header for Radiance vector and math routines
|
| 4 |
|
|
*/
|
| 5 |
|
|
|
| 6 |
|
|
#ifndef _RAD_RTMATH_H_
|
| 7 |
|
|
#define _RAD_RTMATH_H_
|
| 8 |
|
|
|
| 9 |
|
|
#include <math.h>
|
| 10 |
|
|
|
| 11 |
greg |
3.4 |
#include "tiff.h" /* needed for int32, etc. */
|
| 12 |
schorsch |
3.3 |
#include "mat4.h"
|
| 13 |
greg |
3.1 |
|
| 14 |
schorsch |
3.3 |
#ifdef __cplusplus
|
| 15 |
|
|
extern "C" {
|
| 16 |
|
|
#endif
|
| 17 |
greg |
3.1 |
/* regular transformation */
|
| 18 |
|
|
typedef struct {
|
| 19 |
|
|
MAT4 xfm; /* transform matrix */
|
| 20 |
|
|
RREAL sca; /* scalefactor */
|
| 21 |
|
|
} XF;
|
| 22 |
|
|
/* complemetary tranformation */
|
| 23 |
|
|
typedef struct {
|
| 24 |
|
|
XF f; /* forward */
|
| 25 |
|
|
XF b; /* backward */
|
| 26 |
|
|
} FULLXF;
|
| 27 |
|
|
|
| 28 |
|
|
#ifndef PI
|
| 29 |
|
|
#ifdef M_PI
|
| 30 |
|
|
#define PI ((double)M_PI)
|
| 31 |
|
|
#else
|
| 32 |
|
|
#define PI 3.14159265358979323846
|
| 33 |
|
|
#endif
|
| 34 |
|
|
#endif
|
| 35 |
greg |
3.6 |
/* defined in tcos.c */
|
| 36 |
|
|
extern double tcos(double x);
|
| 37 |
|
|
extern double atan2a(double y, double x);
|
| 38 |
greg |
3.1 |
|
| 39 |
greg |
3.7 |
#ifdef __FAST_MATH__
|
| 40 |
greg |
3.1 |
#define tcos cos
|
| 41 |
|
|
#define tsin sin
|
| 42 |
|
|
#define ttan tan
|
| 43 |
|
|
#else
|
| 44 |
greg |
3.14 |
/* table-based approx in tcos.c */
|
| 45 |
greg |
3.1 |
#define tsin(x) tcos((x)-(PI/2.))
|
| 46 |
|
|
#define ttan(x) (tsin(x)/tcos(x))
|
| 47 |
|
|
#endif
|
| 48 |
|
|
/* defined in xf.c */
|
| 49 |
|
|
extern int xf(XF *ret, int ac, char *av[]);
|
| 50 |
|
|
extern int invxf(XF *ret, int ac, char *av[]);
|
| 51 |
|
|
extern int fullxf(FULLXF *fx, int ac, char *av[]);
|
| 52 |
|
|
/* defined in zeroes.c */
|
| 53 |
schorsch |
3.2 |
extern int quadratic(double *r, double a, double b, double c);
|
| 54 |
greg |
3.1 |
/* defined in dircode.c */
|
| 55 |
|
|
extern int32 encodedir(FVECT dv);
|
| 56 |
|
|
extern void decodedir(FVECT dv, int32 dc);
|
| 57 |
|
|
extern double dir2diff(int32 dc1, int32 dc2);
|
| 58 |
|
|
extern double fdir2diff(int32 dc1, FVECT v2);
|
| 59 |
greg |
3.14 |
/* defined in disk2square.c */
|
| 60 |
|
|
extern void SDsquare2disk(double ds[2], double seedx, double seedy);
|
| 61 |
|
|
extern void SDdisk2square(double sq[2], double diskx, double disky);
|
| 62 |
greg |
3.1 |
|
| 63 |
|
|
#ifdef __cplusplus
|
| 64 |
|
|
}
|
| 65 |
|
|
#endif
|
| 66 |
|
|
#endif /* _RAD_RTMATH_H_ */
|
| 67 |
|
|
|