37static bool s_Run_Test_Cases =
true;
41 if( s_Run_Test_Cases ==
false )
44 s_Run_Test_Cases =
true;
54 wxASSERT( bbox2d_A.
Area() == 4.0f );
58 wxASSERT( bbox2d_A.
Max() ==
SFVEC2F( 1.0f, 1.0f ) );
59 wxASSERT( bbox2d_A.
Min() ==
SFVEC2F(-1.0f,-1.0f ) );
60 wxASSERT( bbox2d_A.
Intersects( bbox2d_A ) ==
true );
64 bbox2d_A.
Scale( 2.0f );
67 wxASSERT( bbox2d_A.
Area() == 16.0f );
71 wxASSERT( bbox2d_A.
Max() ==
SFVEC2F( 2.0f, 2.0f ) );
72 wxASSERT( bbox2d_A.
Min() ==
SFVEC2F(-2.0f,-2.0f ) );
73 wxASSERT( bbox2d_A.
Intersects( bbox2d_A ) ==
true );
75 wxASSERT( bbox2d_A.
Perimeter() == 16.0f );
78 wxASSERT( bbox2d_A.
Intersects( bbox2d_B ) ==
false );
80 wxASSERT( bbox2d_A.
Intersects( bbox2d_B ) ==
false );
82 wxASSERT( bbox2d_A.
Intersects( bbox2d_B ) ==
false );
85 wxASSERT( bbox2d_A.
Intersects( bbox2d_B ) ==
true );
87 bbox2d_A.
Union( bbox2d_B );
90 wxASSERT( bbox2d_A.
Area() == 25.0f );
96 wxASSERT( bbox2d_A.
Max() ==
SFVEC2F( 3.0f, 3.0f ) );
97 wxASSERT( bbox2d_A.
Min() ==
SFVEC2F(-2.0f,-2.0f ) );
98 wxASSERT( bbox2d_A.
Intersects( bbox2d_B ) ==
true );
99 wxASSERT( bbox2d_A.
Intersects( bbox2d_A ) ==
true );
101 wxASSERT( bbox2d_A.
Perimeter() == 20.0f );
105 wxASSERT( bbox2d_A.
Intersects( bbox2d_B ) ==
true );
106 wxASSERT( bbox2d_B.
Intersects( bbox2d_A ) ==
true );
109 wxASSERT( bbox2d_A.
Intersects( bbox2d_B ) ==
true );
112 wxASSERT( bbox2d_A.
Intersects( bbox2d_B ) ==
false );
115 wxASSERT( bbox2d_A.
Intersects( bbox2d_B ) ==
true );
120 wxASSERT( filledCircle2d.IsPointInside(
SFVEC2F( 2.0f, 2.0f ) ) ==
true );
122 wxASSERT( filledCircle2d.IsPointInside(
SFVEC2F( 2.0f, 3.0f ) ) ==
true );
123 wxASSERT( filledCircle2d.IsPointInside(
SFVEC2F( 3.0f, 2.0f ) ) ==
true );
124 wxASSERT( filledCircle2d.IsPointInside(
SFVEC2F( 1.0f, 2.0f ) ) ==
true );
125 wxASSERT( filledCircle2d.IsPointInside(
SFVEC2F( 2.0f, 1.0f ) ) ==
true );
127 wxASSERT( filledCircle2d.IsPointInside(
SFVEC2F( 2.8f, 2.8f ) ) ==
false );
128 wxASSERT( filledCircle2d.IsPointInside(
SFVEC2F( 2.6f, 2.6f ) ) ==
true );
129 wxASSERT( filledCircle2d.IsPointInside(
SFVEC2F( 1.2f, 1.2f ) ) ==
false );
132 wxASSERT( filledCircle2d.Intersects( bbox2d_B ) ==
true );
135 wxASSERT( filledCircle2d.Intersects( bbox2d_B ) ==
true );
139 wxASSERT( filledCircle2d.Intersects( bbox2d_B ) ==
false );
142 wxASSERT( filledCircle2d.Intersects( bbox2d_B ) ==
false );
145 wxASSERT( filledCircle2d.Intersects( bbox2d_B ) ==
true );
148 wxASSERT( filledCircle2d.Intersects( bbox2d_B ) ==
true );
151 wxASSERT( filledCircle2d.Intersects( bbox2d_B ) ==
true );
154 wxASSERT( filledCircle2d.Intersects( bbox2d_B ) ==
true );
157 wxASSERT( filledCircle2d.Intersects( bbox2d_B ) ==
true );
163 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( 0.0f, 0.0f ) ) ==
true );
164 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( 1.0f, 0.0f ) ) ==
true );
165 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F(-1.0f, 0.0f ) ) ==
true );
166 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F(-2.0f, 0.0f ) ) ==
true );
167 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( 2.0f, 0.0f ) ) ==
true );
168 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( 0.0f, 1.0f ) ) ==
true );
169 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( 0.0f,-1.0f ) ) ==
true );
170 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( 0.0f, 1.1f ) ) ==
false );
171 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( 0.0f,-1.1f ) ) ==
false );
172 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( 2.1f, 0.0f ) ) ==
false );
173 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( 2.1f, 0.0f ) ) ==
false );
175 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( 1.8f, 0.8f ) ) ==
false );
176 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( 1.8f,-0.8f ) ) ==
false );
178 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( -1.8f, 0.8f ) ) ==
false );
179 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( -1.8f,-0.8f ) ) ==
false );
181 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( 1.6f, 0.6f ) ) ==
true );
182 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( 1.6f,-0.6f ) ) ==
true );
184 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( -1.6f, 0.6f ) ) ==
true );
185 wxASSERT( roundSegment2d.IsPointInside(
SFVEC2F( -1.6f,-0.6f ) ) ==
true );
188 wxASSERT( roundSegment2d.Intersects( bbox2d_A ) ==
true );
191 wxASSERT( roundSegment2d.Intersects( bbox2d_A ) ==
true );
194 wxASSERT( roundSegment2d.Intersects( bbox2d_A ) ==
true );
197 wxASSERT( roundSegment2d.Intersects( bbox2d_A ) ==
true );
200 wxASSERT( roundSegment2d.Intersects( bbox2d_A ) ==
true );
203 wxASSERT( roundSegment2d.Intersects( bbox2d_A ) ==
false );
206 wxASSERT( roundSegment2d.Intersects( bbox2d_A ) ==
false );
209 wxASSERT( roundSegment2d.Intersects( bbox2d_A ) ==
false );
212 wxASSERT( roundSegment2d.Intersects( bbox2d_A ) ==
false );
215 Polygon2d_TestModule();
225 const RAY topLeft( ori, glm::normalize( ori -
SFVEC3F(+1.0,+1.0, z) ) );
226 const RAY topRight( ori, glm::normalize( ori -
SFVEC3F(-1.0,+1.0, z) ) );
227 const RAY bottomLeft( ori, glm::normalize( ori -
SFVEC3F(+1.0,-1.0, z) ) );
228 const RAY bottomRight( ori, glm::normalize( ori -
SFVEC3F(-1.0,-1.0, z) ) );
235 wxASSERT( frustum.
Intersect( bbox3d ) ==
true );
237 bbox3d.
Set(
SFVEC3F( -1.0f, -1.0f, z + z ),
SFVEC3F( +1.0f, +1.0f, z + z + 1.0f ) );
238 wxASSERT( frustum.
Intersect( bbox3d ) ==
true );
241 wxASSERT( frustum.
Intersect( bbox3d ) ==
true );
244 wxASSERT( frustum.
Intersect( bbox3d ) ==
false );
246 bbox3d.
Set(
SFVEC3F( z - 1.0f, z - 1.0f, 0.0 ),
SFVEC3F( z + 1.0f, z + 1.0f, 1.0 ) );
247 wxASSERT( frustum.
Intersect( bbox3d ) ==
false );
250 wxASSERT( frustum.
Intersect( bbox3d ) ==
false );
253 wxASSERT( frustum.
Intersect( bbox3d ) ==
true );
256 wxASSERT( frustum.
Intersect( bbox3d ) ==
true );
259 wxASSERT( frustum.
Intersect( bbox3d ) ==
true );
262 wxASSERT( frustum.
Intersect( bbox3d ) ==
false );
271 const RAY topLeft( ori, glm::normalize(
SFVEC3F( -1.0, 1.0, 0.0 ) - ori ) );
272 const RAY topRight( ori, glm::normalize(
SFVEC3F( +1.0, 1.0, 0.0 ) - ori ) );
273 const RAY bottomLeft( ori, glm::normalize(
SFVEC3F( -1.0, -1.0, 0.0 ) - ori ) );
274 const RAY bottomRight( ori, glm::normalize(
SFVEC3F( +1.0, -1.0, 0.0 ) - ori ) );
281 wxASSERT( frustum.
Intersect( bbox3d ) ==
true );
283 bbox3d.
Set(
SFVEC3F( -1.0f, -1.0f, -( z + z ) ),
SFVEC3F( +1.0f, +1.0f, -( z + z + 1.0f ) ) );
284 wxASSERT( frustum.
Intersect( bbox3d ) ==
true );
287 wxASSERT( frustum.
Intersect( bbox3d ) ==
true );
293 bbox3d.
Set(
SFVEC3F( z - 1.0f, z - 1.0f, 0.0),
SFVEC3F( z + 1.0f, z + 1.0f, 1.0 ) );
294 wxASSERT( frustum.
Intersect( bbox3d ) ==
false );
297 wxASSERT( frustum.
Intersect( bbox3d ) ==
false );
300 wxASSERT( frustum.
Intersect( bbox3d ) ==
true );
303 wxASSERT( frustum.
Intersect( bbox3d ) ==
true );
306 wxASSERT( frustum.
Intersect( bbox3d ) ==
true );
309 wxASSERT( frustum.
Intersect( bbox3d ) ==
false );
2D bounding box class definition.
Bounding Box class definition.
Implement a frustum that is used for ray packet tests.
Manage a bounding box defined by two SFVEC2F min max points.
SFVEC2F GetCenter() const
bool Intersects(const BBOX_2D &aBBox) const
Test if a bounding box intersects this box.
unsigned int MaxDimension() const
SFVEC2F GetExtent() const
void Union(const SFVEC2F &aPoint)
Recalculate the bounding box adding a point.
void Scale(float aScale)
Scale a bounding box by its center.
bool IsInitialized() const
Check if this bounding box is already initialized.
const SFVEC2F & Min() const
float Area() const
Calculate the area of a bounding box.
bool Inside(const SFVEC2F &aPoint) const
Check is a point is inside this bounding box.
const SFVEC2F & Max() const
void Set(const SFVEC2F &aPbMin, const SFVEC2F &aPbMax)
Set bounding box with new parameters.
Manage a bounding box defined by two SFVEC3F min max points.
void Set(const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
Set bounding box with new parameters.
bool Intersect(const BBOX_3D &aBBox) const
Intersect aBBox with this frustum.
void GenerateFrustum(const RAY &topLeft, const RAY &topRight, const RAY &bottomLeft, const RAY &bottomRight)
void Run_3d_viewer_test_cases()