-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclipping_extras.txt
67 lines (55 loc) · 1.45 KB
/
clipping_extras.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
void build_view_window() {
int i;
double x=0,y,z, norm[3];
//hither plane
view_window[0][0] = 0; view_window[0][1] = 0;
view_window[0][2] = hither+1;
view_window[0][3] = -view_window[0][2] * hither;
//yonder plane
view_window[1][0] = 0; view_window[1][1] = 0;
view_window[1][2] = yon+1;
view_window[1][3] = -view_window[1][2] * yon;
y=tan(half_angle)/hither; z = hither;
normal_pts(1,0,0, 0,0,0, x,y,z, view_window[2]);
view_window[2][3] =
- view_window[2][0] * x
- view_window[2][1] * y
- view_window[2][2] * z;
y = -y;
normal_pts(1,0,0, 0,0,0, x,y,z, view_window[3]);
view_window[3][3] =
- view_window[3][0] * x
- view_window[3][1] * y
- view_window[3][2] * z;
x = -y; y=0;
normal_pts(0,1,0, 0,0,0, x,y,z, view_window[4]);
view_window[4][3] =
- view_window[4][0] * x
- view_window[4][1] * y
- view_window[4][2] * z;
x = -x;
normal_pts(0,1,0, 0,0,0, x,y,z, view_window[5]);
view_window[5][3] =
- view_window[5][0] * x
- view_window[5][1] * y
- view_window[5][2] * z;
}
int in_view(double xyz[3]) {
double checkp[3] = {0,0,hither+yon/2};
double p,check;
int i;
for (i=0; i<6; i++) { //check edge planes
p = add(xyz,i);
check = add(checkp,i);
if(sgn(p) != sgn (check)) {return 0;}
}
return 1; //point is in view
}
double add(double xyz[3], int i){
return view_window[i][0] * xyz[0] +
view_window[i][1] * xyz[1] +
view_window[i][2] * xyz[2] +
view_window[i][3];
}
**/