48 Set( aPbMin, aPbMax );
59 m_min.x = fminf( aPbMin.x, aPbMax.x );
60 m_min.y = fminf( aPbMin.y, aPbMax.y );
62 m_max.x = fmaxf( aPbMin.x, aPbMax.x );
63 m_max.y = fmaxf( aPbMin.y, aPbMax.y );
77 return !( ( FLT_MAX ==
m_min.x ) || ( FLT_MAX ==
m_min.y ) || ( -FLT_MAX ==
m_max.x )
78 || ( -FLT_MAX ==
m_max.y ) );
132 if( extent.y > extent.x )
result = 1;
142 return 2.0f * ( extent.x + extent.y );
150 const SFVEC2F scaleV( aScale, aScale );
153 m_min = (
m_min - centerV ) * scaleV + centerV;
154 m_max = (
m_max - centerV ) * scaleV + centerV;
182 float fDistSq = 0.0f;
184 for(
unsigned int i = 0; i < 2; i++ )
186 if( aCenter[i] <
m_min[i] )
188 const float fDist = aCenter[i] -
m_min[i];
190 fDistSq += fDist * fDist;
194 if( aCenter[i] >
m_max[i] )
196 const float fDist = aCenter[i] -
m_max[i];
198 fDistSq += fDist * fDist;
203 return ( fDistSq <= aRadiusSquared );
223 return ( ( aPoint.x >=
m_min.x ) && ( aPoint.x <=
m_max.x ) &&
224 ( aPoint.y >=
m_min.y ) && ( aPoint.y <=
m_max.y ) );
241 return extent.x * extent.y;
253 float tmin = glm::min( tx1, tx2 );
254 float tmax = glm::max( tx1, tx2 );
259 tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
260 tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
267 return ( tmax >= 0.0f ) && ( tmax >= tmin );
276 float tmin = glm::min( tx1, tx2 );
277 float tmax = glm::max( tx1, tx2 );
282 tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
283 tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
285 if( (tmax >= 0.0f) && (tmax >= tmin) )
287 const float t = (tmin > 0.0f)?tmin:tmax;
298 wxASSERT( aOutHitT0 );
299 wxASSERT( aOutHitT1 );
304 float tmin = glm::min( tx1, tx2 );
305 float tmax = glm::max( tx1, tx2 );
310 tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
311 tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
313 *aOutHitT0 = ( tmin > 0.0f ) ? tmin : 0.0f;
316 return ( tmax >= 0.0f ) && ( tmax >= tmin );
Defines math related functions.
float NextFloatDown(float v)
float NextFloatUp(float v)
2D bounding box class definition.
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
wxString result
Test unit parsing edge cases and error handling.