ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/sm_geom.h
Revision: 3.4
Committed: Wed Sep 16 18:16:28 1998 UTC (25 years, 7 months ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 3.3: +13 -0 lines
Log Message:
implemented integer triangle tracing

File Contents

# Content
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 #include <values.h>
12
13 #define ZERO(x) ((x) < FTINY && (x) > -FTINY)
14 #define EQUAL(a,b) ZERO((a) - (b))
15
16 #ifndef TRUE
17 #define TRUE 1
18 #define FALSE 0
19 #endif
20
21 typedef long BCOORD;
22 typedef long BDIR;
23 typedef long TINT;
24 #define BITS_BCOORD (BITS(long)>>1)
25 #define SHIFT_MAXBCOORD (BITS_BCOORD-2)
26 #define MAXBCOORD (1L << SHIFT_MAXBCOORD)
27 #define MAXBCOORD2 (MAXBCOORD>>1)
28 #define MAXBDIR MAXBCOORD
29 #define MAXT MAXBCOORD
30 #define HUGET MAXLONG
31
32 #define M_2_3_PI PI*2/3
33
34 #define INVALID -1
35
36 #define GT_INVALID 0
37 #define GT_VERTEX 1
38 #define GT_EDGE 2
39 #define GT_FACE 4
40 #define GT_INTERIOR 8
41 #define GT_INTERSECT 16
42 #define GT_ADJACENT 32
43 #define GT_OUT 64
44
45 #define ZERO_VEC3(v) (ZERO(v[0]) && ZERO(v[1]) && ZERO(v[2]) )
46 #define EQUAL_VEC3(a,b) (EQUAL(a[0],b[0])&&EQUAL(a[1],b[1])&&EQUAL(a[2],b[2]))
47 #define NEGATE_VEC3(v) ((v)[0] *= -1.0,(v)[1] *= -1.0,(v)[2] *= -1.0)
48 #define COPY_VEC2(v1,v2) ((v1)[0]=(v2)[0],(v1)[1]=(v2)[1])
49 #define DIST(a,b) (sqrt(((a)[0]-(b)[0])*((a)[0]-(b)[0]) + \
50 ((a)[1]-(b)[1])*((a)[1]-(b)[1]) + \
51 ((a)[2]-(b)[2])*((a)[2]-(b)[2])))
52 #define DIST_SQ(a,b) (((a)[0]-(b)[0])*((a)[0]-(b)[0]) + \
53 ((a)[1]-(b)[1])*((a)[1]-(b)[1]) + \
54 ((a)[2]-(b)[2])*((a)[2]-(b)[2]))
55
56 #define CROSS_VEC2(v1,v2) (((v1)[0]*(v2)[1]) - ((v1)[1]*(v2)[0]))
57 #define DOT_VEC2(v1,v2) ((v1)[0]*(v2)[0] + (v1)[1]*(v2)[1])
58
59 #define EDGE_MIDPOINT_VEC3(a,v1,v2) ((a)[0]=((v1)[0]+(v2)[0])*0.5, \
60 (a)[1]=((v1)[1]+(v2)[1])*0.5,(a)[2] = ((v1)[2]+(v2)[2])*0.5)
61
62 #define MIN_VEC3(v) ((v)[0]<(v)[1]?((v)[0]<(v)[2]?(v)[0]:v[2]): \
63 (v)[1]<(v)[2]?(v)[1]:(v)[2])
64
65
66 #define SUM_3VEC3(r,a,b,c) ((r)[0]=(a)[0]+(b)[0]+(c)[0], \
67 (r)[1]=(a)[1]+(b)[1]+(c)[1],(r)[2]=(a)[2]+(b)[2]+(c)[2])
68
69 #define NTH_BIT(n,i) ((n) & (1<<(i)))
70 #define SET_NTH_BIT(n,i) ((n) |= (1<<(i)))
71
72
73 /* int convex_angle(FVECT v0,FVECT v1,FVECT v2) */
74 /* void triangle_centroid(FVECT v0,FVECT v1,FVECT v2,FVECT c) */
75 /* void triangle_plane_equation(FVECT v0,FVECT v1,FVECT v2,FVECT n,double *nd,
76 char norm) */
77 /* int vec3_equal(FVECT v1,v2) */
78 /* int point_relative_to_plane(FVECT p,FVECT n, double nd) */
79 /* int point_in_circle(FVECT p,FVECT p0,FVECT p1) */
80 /* int intersect_line_plane(FVECT r,FVECT p1,FVECT p2,float *plane) */
81 /* int point_in_cone(FVECT p,FVECT p1,FVECT p2,FVECT p3,FVECT p4) */
82 /* void point_on_sphere(FVECT ps,FVECT p,FVECT c) */
83 /* int test_point_against_spherical_tri(FVECT v0,FVECT v1,FVECT v2,FVECT p,
84 FVECT n,char *nset,char *which,char sides[3]) */
85 /* int test_single_point_against_spherical_tri(FVECT v0,FVECT v1,FVECT v2,
86 FVECT p,char *which )*/
87 /* int test_vertices_for_tri_inclusion(FVECT tri[3],FVECT pts[3],char *nset,
88 FVECT n[3],FVECT avg,char pt_sides[3][3]); */
89 /* void set_sidedness_tests(FVECT tri[3],FVECT pts[3],char test[3],
90 char sides[3][3],char nset,FVECT n[3])
91 */
92 /* int cs_spherical_edge_edge_test(FVECT n[2][3],int i,int j,FVECT avg[2]) */
93 /* int spherical_tri_tri_intersect(FVECT a1,FVECT a2,FVECT a3,
94 FVECT b1,FVECT b2,FVECT b3) */
95
96 /* void calculate_view_frustum(FVECT vp,hv,vv,double horiz,vert,near,far,
97 FVECT fnear[4],FVECT ffar[4])
98 */
99 /* double triangle_normal_Newell(FVECT v0,FVECT v1,FVECT v2,FVECT n,char n)*/
100 double tri_normal();
101 /* double spherical_edge_normal(FVECT v0,FVECT v1,FVECT n,char norm) */
102 double spherical_edge_normal();
103
104