ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/sm_geom.h
Revision: 3.6
Committed: Wed Nov 11 12:05:39 1998 UTC (25 years, 5 months ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 3.5: +8 -1 lines
Log Message:
new triangulation code
changed triangle vertex order to CCW
changed numbering of triangle neighbors to match quadtree
fixed tone-mapping bug
removed errant printf() statements
redid logic for adding and testing samples with new epsilon

File Contents

# User Rev Content
1 gwlarson 3.1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2    
3     /* SCCSid "$SunId$ SGI" */
4    
5     /*
6     * sm_geom.h
7     */
8    
9     /* Assumes included after standard.h */
10    
11 gwlarson 3.4 #include <values.h>
12    
13 gwlarson 3.6 #define F_TINY 1e-3
14    
15     #define FZERO(x) ((x) < F_TINY && (x) > -F_TINY)
16     #define FEQUAL(a,b) FZERO((a) - (b))
17    
18 gwlarson 3.1 #define ZERO(x) ((x) < FTINY && (x) > -FTINY)
19     #define EQUAL(a,b) ZERO((a) - (b))
20    
21     #ifndef TRUE
22     #define TRUE 1
23     #define FALSE 0
24     #endif
25 gwlarson 3.4
26 gwlarson 3.5 typedef struct _FPEQ {
27     FVECT n;
28     double d;
29     char x,y,z;
30     }FPEQ;
31    
32     #define FP_N(f) ((f).n)
33     #define FP_D(f) ((f).d)
34     #define FP_X(f) ((f).x)
35     #define FP_Y(f) ((f).y)
36     #define FP_Z(f) ((f).z)
37    
38 gwlarson 3.4 typedef long BCOORD;
39     typedef long BDIR;
40     typedef long TINT;
41     #define BITS_BCOORD (BITS(long)>>1)
42     #define SHIFT_MAXBCOORD (BITS_BCOORD-2)
43     #define MAXBCOORD (1L << SHIFT_MAXBCOORD)
44     #define MAXBCOORD2 (MAXBCOORD>>1)
45     #define MAXBDIR MAXBCOORD
46     #define MAXT MAXBCOORD
47     #define HUGET MAXLONG
48 gwlarson 3.1
49     #define M_2_3_PI PI*2/3
50    
51 gwlarson 3.5 #ifndef INVALID
52 gwlarson 3.3 #define INVALID -1
53 gwlarson 3.5 #endif
54 gwlarson 3.3
55 gwlarson 3.1 #define GT_INVALID 0
56     #define GT_VERTEX 1
57     #define GT_EDGE 2
58     #define GT_FACE 4
59     #define GT_INTERIOR 8
60     #define GT_INTERSECT 16
61     #define GT_ADJACENT 32
62     #define GT_OUT 64
63    
64     #define ZERO_VEC3(v) (ZERO(v[0]) && ZERO(v[1]) && ZERO(v[2]) )
65     #define EQUAL_VEC3(a,b) (EQUAL(a[0],b[0])&&EQUAL(a[1],b[1])&&EQUAL(a[2],b[2]))
66 gwlarson 3.6 #define FZERO_VEC3(v) (FZERO(v[0]) && FZERO(v[1]) && FZERO(v[2]) )
67     #define FEQUAL_VEC3(a,b) (FEQUAL(a[0],b[0])&&FEQUAL(a[1],b[1])&&FEQUAL(a[2],b[2]))
68 gwlarson 3.1 #define NEGATE_VEC3(v) ((v)[0] *= -1.0,(v)[1] *= -1.0,(v)[2] *= -1.0)
69     #define COPY_VEC2(v1,v2) ((v1)[0]=(v2)[0],(v1)[1]=(v2)[1])
70     #define DIST(a,b) (sqrt(((a)[0]-(b)[0])*((a)[0]-(b)[0]) + \
71     ((a)[1]-(b)[1])*((a)[1]-(b)[1]) + \
72     ((a)[2]-(b)[2])*((a)[2]-(b)[2])))
73 gwlarson 3.3 #define DIST_SQ(a,b) (((a)[0]-(b)[0])*((a)[0]-(b)[0]) + \
74     ((a)[1]-(b)[1])*((a)[1]-(b)[1]) + \
75     ((a)[2]-(b)[2])*((a)[2]-(b)[2]))
76 gwlarson 3.1
77     #define CROSS_VEC2(v1,v2) (((v1)[0]*(v2)[1]) - ((v1)[1]*(v2)[0]))
78     #define DOT_VEC2(v1,v2) ((v1)[0]*(v2)[0] + (v1)[1]*(v2)[1])
79    
80     #define EDGE_MIDPOINT_VEC3(a,v1,v2) ((a)[0]=((v1)[0]+(v2)[0])*0.5, \
81     (a)[1]=((v1)[1]+(v2)[1])*0.5,(a)[2] = ((v1)[2]+(v2)[2])*0.5)
82    
83     #define MIN_VEC3(v) ((v)[0]<(v)[1]?((v)[0]<(v)[2]?(v)[0]:v[2]): \
84     (v)[1]<(v)[2]?(v)[1]:(v)[2])
85 gwlarson 3.5 #define MAX3(a,b,c) (((b)>(a))?((b) > (c))?(b):(c):((a)>(c))?(a):(c))
86     #define MIN3(a,b,c) (((b)<(a))?((b) < (c))?(b):(c):((a)<(c))?(a):(c))
87     #define MAX(a,b) (((b)>(a))?(b):(a))
88     #define MIN(a,b) (((b)<(a))?(b):(a))
89 gwlarson 3.2
90 gwlarson 3.1 #define SUM_3VEC3(r,a,b,c) ((r)[0]=(a)[0]+(b)[0]+(c)[0], \
91     (r)[1]=(a)[1]+(b)[1]+(c)[1],(r)[2]=(a)[2]+(b)[2]+(c)[2])
92    
93     #define NTH_BIT(n,i) ((n) & (1<<(i)))
94     #define SET_NTH_BIT(n,i) ((n) |= (1<<(i)))
95    
96    
97     /* int convex_angle(FVECT v0,FVECT v1,FVECT v2) */
98     /* void triangle_centroid(FVECT v0,FVECT v1,FVECT v2,FVECT c) */
99     /* void triangle_plane_equation(FVECT v0,FVECT v1,FVECT v2,FVECT n,double *nd,
100     char norm) */
101     /* int vec3_equal(FVECT v1,v2) */
102     /* int point_relative_to_plane(FVECT p,FVECT n, double nd) */
103     /* int point_in_circle(FVECT p,FVECT p0,FVECT p1) */
104     /* int intersect_line_plane(FVECT r,FVECT p1,FVECT p2,float *plane) */
105     /* int point_in_cone(FVECT p,FVECT p1,FVECT p2,FVECT p3,FVECT p4) */
106     /* void point_on_sphere(FVECT ps,FVECT p,FVECT c) */
107     /* int test_point_against_spherical_tri(FVECT v0,FVECT v1,FVECT v2,FVECT p,
108     FVECT n,char *nset,char *which,char sides[3]) */
109     /* int test_single_point_against_spherical_tri(FVECT v0,FVECT v1,FVECT v2,
110     FVECT p,char *which )*/
111     /* int test_vertices_for_tri_inclusion(FVECT tri[3],FVECT pts[3],char *nset,
112     FVECT n[3],FVECT avg,char pt_sides[3][3]); */
113     /* void set_sidedness_tests(FVECT tri[3],FVECT pts[3],char test[3],
114     char sides[3][3],char nset,FVECT n[3])
115     */
116     /* int cs_spherical_edge_edge_test(FVECT n[2][3],int i,int j,FVECT avg[2]) */
117     /* int spherical_tri_tri_intersect(FVECT a1,FVECT a2,FVECT a3,
118     FVECT b1,FVECT b2,FVECT b3) */
119    
120     /* void calculate_view_frustum(FVECT vp,hv,vv,double horiz,vert,near,far,
121     FVECT fnear[4],FVECT ffar[4])
122     */
123     /* double triangle_normal_Newell(FVECT v0,FVECT v1,FVECT v2,FVECT n,char n)*/
124     double tri_normal();
125     /* double spherical_edge_normal(FVECT v0,FVECT v1,FVECT n,char norm) */
126     double spherical_edge_normal();
127    
128 gwlarson 3.5 #define point_in_stri_n(n0,n1,n2,p) \
129 gwlarson 3.6 ((DOT(n0,p)<=F_TINY)&&(DOT(n1,p)<=F_TINY)&&(DOT(n2,p)<=F_TINY))
130 gwlarson 3.1
131 gwlarson 3.5 #define PT_ON_PLANE(p,peq) (DOT(FP_N(peq),p)+FP_D(peq))