52 Set( aPbMin, aPbMax );
63 m_min.x = fminf( aPbMin.x, aPbMax.x );
64 m_min.y = fminf( aPbMin.y, aPbMax.y );
66 m_max.x = fmaxf( aPbMin.x, aPbMax.x );
67 m_max.y = fmaxf( aPbMin.y, aPbMax.y );
81 return !( ( FLT_MAX ==
m_min.x ) || ( FLT_MAX ==
m_min.y ) || ( -FLT_MAX ==
m_max.x )
82 || ( -FLT_MAX ==
m_max.y ) );
133 unsigned int result = 0;
136 if( extent.y > extent.x ) result = 1;
146 return 2.0f * ( extent.x + extent.y );
154 const SFVEC2F scaleV( aScale, aScale );
157 m_min = (
m_min - centerV ) * scaleV + centerV;
158 m_max = (
m_max - centerV ) * scaleV + centerV;
186 float fDistSq = 0.0f;
188 for(
unsigned int i = 0; i < 2; i++ )
190 if( aCenter[i] <
m_min[i] )
192 const float fDist = aCenter[i] -
m_min[i];
194 fDistSq += fDist * fDist;
198 if( aCenter[i] >
m_max[i] )
200 const float fDist = aCenter[i] -
m_max[i];
202 fDistSq += fDist * fDist;
207 return ( fDistSq <= aRadiusSquared );
227 return ( ( aPoint.x >=
m_min.x ) && ( aPoint.x <=
m_max.x ) &&
228 ( aPoint.y >=
m_min.y ) && ( aPoint.y <=
m_max.y ) );
245 return extent.x * extent.y;
257 float tmin = glm::min( tx1, tx2 );
258 float tmax = glm::max( tx1, tx2 );
263 tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
264 tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
271 return (tmax >= 0.0f) && (tmax >= tmin);
280 float tmin = glm::min( tx1, tx2 );
281 float tmax = glm::max( tx1, tx2 );
286 tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
287 tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
289 if( (tmax >= 0.0f) && (tmax >= tmin) )
291 const float t = (tmin > 0.0f)?tmin:tmax;
302 wxASSERT( aOutHitT0 );
303 wxASSERT( aOutHitT1 );
308 float tmin = glm::min( tx1, tx2 );
309 float tmax = glm::max( tx1, tx2 );
314 tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
315 tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
317 *aOutHitT0 = ( tmin > 0.0f ) ? tmin : 0.0f;
320 return ( tmax >= 0.0f ) && ( tmax >= tmin );
Defines math related functions.
float NextFloatDown(float v)
float NextFloatUp(float v)
2D bounding box class definition.
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 m_min
point of the lower position of the bounding box
void ScaleNextDown()
Scale a bounding box to the next float representation making it smaller.
SFVEC2F GetExtent() const
SFVEC2F m_max
point of the higher position of the bounding box
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.
BBOX_2D()
Create with default values a bounding box (not initialized).
void Reset()
Reset the bounding box to zero and uninitialize it.
const SFVEC2F & Max() const
void Set(const SFVEC2F &aPbMin, const SFVEC2F &aPbMax)
Set bounding box with new parameters.
void ScaleNextUp()
Scale a bounding box to the next float representation making it larger.
bool Intersect(const RAY2D &aRay, float *t) const