5 |
|
* G. Ward |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#ifndef _BSDFREP_H_ |
9 |
+ |
#define _BSDFREP_H_ |
10 |
+ |
|
11 |
|
#include "bsdf.h" |
12 |
|
|
13 |
< |
#define DEBUG 1 |
13 |
> |
#ifdef __cplusplus |
14 |
> |
extern "C" { |
15 |
> |
#endif |
16 |
|
|
17 |
|
#ifndef GRIDRES |
18 |
< |
#define GRIDRES 200 /* grid resolution per side */ |
18 |
> |
#define GRIDRES (1<<8) /* grid resolution per side */ |
19 |
|
#endif |
20 |
|
/* convert to/from coded radians */ |
21 |
|
#define ANG2R(r) (int)((r)*((1<<16)/M_PI)) |
22 |
|
#define R2ANG(c) (((c)+.5)*(M_PI/(1<<16))) |
23 |
|
|
24 |
< |
typedef struct { |
25 |
< |
float vsum; /* DSF sum */ |
26 |
< |
unsigned short nval; /* number of values in sum */ |
27 |
< |
unsigned short crad; /* radius (coded angle) */ |
24 |
> |
/* moderated cosine factor */ |
25 |
> |
#define COSF(z) (fabs(z)*0.98 + 0.02) |
26 |
> |
|
27 |
> |
typedef union { |
28 |
> |
struct { |
29 |
> |
float v; /* DSF sum */ |
30 |
> |
unsigned int n; /* number of values in sum */ |
31 |
> |
} sum; /* sum for averaging */ |
32 |
> |
float val[2]; /* comparison values */ |
33 |
|
} GRIDVAL; /* grid value */ |
34 |
|
|
35 |
|
typedef struct { |
67 |
|
#define INP_QUAD3 4 /* 180-270 degree quadrant */ |
68 |
|
#define INP_QUAD4 8 /* 270-360 degree quadrant */ |
69 |
|
|
70 |
+ |
/* name and manufacturer if known */ |
71 |
+ |
extern char bsdf_name[]; |
72 |
+ |
extern char bsdf_manuf[]; |
73 |
|
/* active grid resolution */ |
74 |
|
extern int grid_res; |
75 |
|
/* coverage/symmetry using INP_QUAD? flags */ |
87 |
|
#define BSDF2BIG (1./M_PI) |
88 |
|
#define BSDF2SML 1e-8 |
89 |
|
#define HISTLNR 17.2759509 /* log(BSDF2BIG/BSDF2SML) */ |
90 |
< |
extern int bsdf_hist[HISTLEN]; |
90 |
> |
extern unsigned long bsdf_hist[HISTLEN]; |
91 |
|
#define histndx(v) (int)(log((v)*(1./BSDF2SML))*(HISTLEN/HISTLNR)) |
92 |
|
#define histval(i) (exp(((i)+.5)*(HISTLNR/HISTLEN))*BSDF2SML) |
93 |
|
|
94 |
|
/* BSDF value for boundary regions */ |
95 |
|
extern double bsdf_min; |
96 |
+ |
extern double bsdf_spec_peak; |
97 |
+ |
extern double bsdf_spec_rad; |
98 |
|
|
99 |
|
/* processed incident DSF measurements */ |
100 |
|
extern RBFNODE *dsf_list; |
118 |
|
extern char *progname; |
119 |
|
|
120 |
|
/* get theta value in degrees [0,180) range */ |
121 |
< |
#define get_theta180(v) ((180./M_PI)*acos((v)[2])) |
121 |
> |
#define get_theta180(v) ((180./M_PI)*Acos((v)[2])) |
122 |
|
/* get phi value in degrees, [0,360) range */ |
123 |
|
#define get_phi360(v) ((180./M_PI)*atan2((v)[1],(v)[0]) + 360.*((v)[1]<0)) |
124 |
|
|
153 |
|
/* Compute grid position from normalized input/output vector */ |
154 |
|
extern void pos_from_vec(int pos[2], const FVECT vec); |
155 |
|
|
156 |
< |
/* Evaluate RBF for DSF at the given normalized outgoing direction */ |
156 |
> |
/* Evaluate BSDF at the given normalized outgoing direction */ |
157 |
|
extern double eval_rbfrep(const RBFNODE *rp, const FVECT outvec); |
158 |
|
|
159 |
|
/* Insert a new directional scattering function in our global list */ |
198 |
|
/* Find edge(s) for interpolating the given vector, applying symmetry */ |
199 |
|
extern int get_interp(MIGRATION *miga[3], FVECT invec); |
200 |
|
|
201 |
+ |
/* Return single-lobe specular RBF for the given incident direction */ |
202 |
+ |
extern RBFNODE * def_rbf_spec(const FVECT invec); |
203 |
+ |
|
204 |
+ |
/* Advect and allocate new RBF along edge (internal call) */ |
205 |
+ |
extern RBFNODE * e_advect_rbf(const MIGRATION *mig, |
206 |
+ |
const FVECT invec, int lobe_lim); |
207 |
+ |
|
208 |
+ |
/* Compute distance between two RBF lobes (internal call) */ |
209 |
+ |
extern double lobe_distance(RBFVAL *rbf1, RBFVAL *rbf2); |
210 |
+ |
|
211 |
+ |
/* Compute mass transport plan (internal call) */ |
212 |
+ |
extern void plan_transport(MIGRATION *mig); |
213 |
+ |
|
214 |
|
/* Partially advect between recorded incident angles and allocate new RBF */ |
215 |
< |
extern RBFNODE * advect_rbf(const FVECT invec); |
215 |
> |
extern RBFNODE * advect_rbf(const FVECT invec, int lobe_lim); |
216 |
> |
|
217 |
> |
#ifdef __cplusplus |
218 |
> |
} |
219 |
> |
#endif |
220 |
> |
#endif /* _BSDFREP_H_ */ |