30#include "../../../3d_fastmath.h"
39 wxASSERT( aInnerRadius < aOuterRadius );
81 const float qd = qx * aSegRay.
m_Dir.x + qy * aSegRay.
m_Dir.y;
82 const float qq = qx * qx + qy * qy;
86 const float discriminantsqr = qd * qd - qq;
90 if( discriminantsqr_outer < FLT_EPSILON )
95 const float discriminant = sqrt( discriminantsqr_outer );
96 float t = ( -qd - discriminant );
98 if( ( t > FLT_EPSILON ) && ( t < aSegRay.
m_Length ) )
110 if( discriminantsqr_inter > FLT_EPSILON )
112 const float discriminant_inner = sqrt( discriminantsqr_inter );
114 const float t2_inner = ( -qd + discriminant_inner );
116 if( ( t2_inner > FLT_EPSILON ) && ( t2_inner < aSegRay.
m_Length ) )
122 const SFVEC2F hitPoint = aSegRay.
at( t2_inner );
138 wxASSERT( (t > 0.0f) && (t <= aSegRay.
m_Length) );
150 return INTERSECTION_RESULT::MISSES;
158 const float dot = glm::dot( v, v );
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
bool Intersects(const BBOX_2D &aBBox) const override
a.Intersects(b) ⇔ !a.Disjoint(b) ⇔ !(a ∩ b = ∅)
RING_2D(const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, const BOARD_ITEM &aBoardItem)
bool Overlaps(const BBOX_2D &aBBox) const override
Test if the box overlaps the object.
bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const override
INTERSECTION_RESULT IsBBoxInside(const BBOX_2D &aBBox) const override
Test this object if it's completely outside, intersects, or is completely inside aBBox.
float m_inner_radius_squared
bool IsPointInside(const SFVEC2F &aPoint) const override
float m_outer_radius_squared
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.
bool IsInitialized() const
Check if this bounding box is already initialized.
void Reset()
Reset the bounding box to zero and uninitialize it.
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.
SFVEC2F at(float t) const