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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// Copyright Jeron A. Lau 2017-2018.
// Copyright Douglas Lau 2017
// Dual-licensed under either the MIT License or the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
use fmt;
use Vector;
use BCube;
/// Single-precision plane
/*#[test]
fn test_plane_distpos() {
let t = ::Transform::new()
.rotate(-10.0, 20.0, -5.0)
.translate(500.0, -100.0, -115.0)
.rotate(1.0, 2.0, 0.3);
let a = Plane::new(t * Vector::new(0.0, 1.0, 0.0), Vector::new(0.0, 1.0, 0.0).transform_dir(t));
let b = Plane::new(t * Vector::new(0.0, 0.0, 1.0), Vector::new(0.0, 0.0, -1.0).transform_dir(t));
let c = Plane::new(t * Vector::new(0.0, 0.0, 0.0), Vector::new(0.0, 0.0, 1.0).transform_dir(t));
assert!(a.isdistpos_point(t * Vector::new(-12.0, 2.0, 0.0)) == true);
assert!(a.isdistpos_point(t * Vector::new(-12.0, 0.0, 0.0)) == false);
assert!(b.isdistpos_point(t * Vector::new(15.0, 0.0, -12.0)) == true);
assert!(b.isdistpos_point(t * Vector::new(15.0, 0.0, 12.0)) == false);
assert!(c.isdistpos_point(t * Vector::new(5.0, -10.0, 0.5)) == true);
assert!(c.isdistpos_point(t * Vector::new(-5.0, -10.0, -0.5)) == false);
}*/
/*#[test]
fn test_bcube_in_plane() {
let t = ::Transform::new()
.rotate(-10.0, 20.0, -5.0)
.translate(500.0, -100.0, -115.0)
.rotate(1.0, 2.0, 0.3);
// Plane is behind box
let a = Plane::new(Vector::new(0.0, 0.0, 1.0)/*.transform_dir(t)*/, -2.5);
// Plane intersects box
let b = Plane::new(Vector::new(0.0, 0.0, 1.0)/*.transform_dir(t)*/, 0.0);
// Plane is in front of box, plz cull
let c = Plane::new(Vector::new(0.0, 0.0, 1.0)/*.transform_dir(t)*/, 2.5);
// Plane intersects box at 45° angle
let d = Plane::new(Vector::new(0.0, 0.0, 1.0).transform_dir(
::Transform::new()
.rotate(0.0, -0.5, 0.0)), 0.0);
// Plane intersects box at 135° angle
let e = Plane::new(Vector::new(0.0, 0.0, 1.0).transform_dir(
::Transform::new()
.rotate(0.0, -1.5, 0.0)), 0.0);
// Plane is behind box from 45° angle.
let f = Plane::new(Vector::new(0.0, 0.0, 1.0).transform_dir(
::Transform::new()
.rotate(0.0, 0.25, 0.0)), -2.5);
// Plane is behind box from 135° angle.
let g = Plane::new(Vector::new(0.0, 0.0, 1.0).transform_dir(
::Transform::new()
.rotate(0.0, 0.75, 0.0)), -2.5);
// Plane is behind box from 225° angle.
let h = Plane::new(Vector::new(0.0, 0.0, 1.0).transform_dir(
::Transform::new()
.rotate(0.0, 1.25, 0.0)), -2.5);
// Plane is behind box from 315° angle.
let i = Plane::new(Vector::new(0.0, 0.0, 1.0).transform_dir(
::Transform::new()
.rotate(0.0, 1.75, 0.0)), -2.5);
assert!(a.isdistpos_bcube(BCube::new(Vector::new(0, 0.0, 0.0))) == true);
assert!(b.isdistpos_bcube(BCube::new(Vector::new(0, 0.0, 0.0))) == true);
assert!(c.isdistpos_bcube(BCube::new(Vector::new(0, 0.0, 0.0))) == false);
assert!(d.isdistpos_bcube(BCube::new(Vector::new(0, 0.0, 0.0))) == true);
assert!(e.isdistpos_bcube(BCube::new(Vector::new(0, 0.0, 0.0))) == true);
assert!(f.isdistpos_bcube(BCube::new(Vector::new(0, 0.0, 0.0))) == true);
assert!(g.isdistpos_bcube(BCube::new(Vector::new(0, 0.0, 0.0))) == true);
assert!(h.isdistpos_bcube(BCube::new(Vector::new(0, 0.0, 0.0))) == true);
assert!(i.isdistpos_bcube(BCube::new(Vector::new(0, 0.0, 0.0))) == true);
assert!(a.isdistpos_bcube(BCube::new(Vector::new(0, -2.0, 0.0))) == true);
assert!(b.isdistpos_bcube(BCube::new(Vector::new(0, -2.0, 0.0))) == true);
assert!(c.isdistpos_bcube(BCube::new(Vector::new(0, -2.0, 0.0))) == false);
assert!(d.isdistpos_bcube(BCube::new(Vector::new(0, -2.0, 0.0))) == true);
assert!(e.isdistpos_bcube(BCube::new(Vector::new(0, -2.0, 0.0))) == true);
assert!(f.isdistpos_bcube(BCube::new(Vector::new(0, -2.0, 0.0))) == true);
assert!(g.isdistpos_bcube(BCube::new(Vector::new(0, -2.0, 0.0))) == true);
assert!(h.isdistpos_bcube(BCube::new(Vector::new(0, -2.0, 0.0))) == true);
assert!(i.isdistpos_bcube(BCube::new(Vector::new(0, -2.0, 0.0))) == true);
}*/