26#include "../../3d_fastmath.h"
86 else if(
m_Dir.z > 0 )
108 else if(
m_Dir.z == 0 )
110 else if(
m_Dir.y == 0 )
132 else if(
m_Dir.z == 0 )
134 else if(
m_Dir.x == 0 )
146 else if(
m_Dir.x == 0 )
148 else if(
m_Dir.y == 0 )
159 else if(
m_Dir.z == 0 )
168 else if(
m_Dir.y == 0 )
170 else if(
m_Dir.z == 0 )
184 float rxs = aEnd_minus_startA.x * aEnd_minus_startB.y - aEnd_minus_startA.y *
187 if(
std::abs( rxs ) > glm::epsilon<float>() )
189 float inv_rxs = 1.0f / rxs;
191 SFVEC2F pq = aStartB - aStartA;
193 float t = ( pq.x * aEnd_minus_startB.y - pq.y * aEnd_minus_startB.x ) * inv_rxs;
195 if( ( t < 0.0f ) || ( t > 1.0f ) )
198 float u = ( pq.x * aEnd_minus_startA.y - pq.y * aEnd_minus_startA.x ) * inv_rxs;
200 if( ( u < 0.0f ) || ( u > 1.0f ) )
212 float &aOutT1 )
const
216 float p_dot_d = glm::dot( OC,
m_Dir );
221 float p_dot_p = glm::dot( OC, OC );
222 float discriminant = p_dot_p - p_dot_d * p_dot_d;
224 if( discriminant > aRadius*aRadius )
227 discriminant = sqrtf( aRadius*aRadius - discriminant );
229 aOutT0 = p_dot_d - discriminant;
230 aOutT1 = p_dot_d + discriminant;
232 if( aOutT0 > aOutT1 )
252 if( fabs(
m_Dir.x ) < FLT_EPSILON )
255 if( fabs(
m_Dir.y ) < FLT_EPSILON )
268 if(
std::abs( rxs ) > glm::epsilon<float>() )
270 const float inv_rxs = 1.0f / rxs;
274 const float t = ( pq.x * aEnd_minus_start.y - pq.y * aEnd_minus_start.x ) * inv_rxs;
276 if( ( t < 0.0f ) || ( t > 1.0f ) )
281 if( ( u < 0.0f ) || ( u > 1.0f ) )
300 if( c1 < FLT_EPSILON )
301 return glm::dot( p, p );
315 return glm::dot( p, p );
320 float *aOutT1,
SFVEC2F *aOutNormalT0,
SFVEC2F *aOutNormalT1 )
const
326 const float qx =
m_Start.x - aCenter.x;
327 const float qy =
m_Start.y - aCenter.y;
330 const float qq = qx * qx + qy * qy;
334 const float discriminantsqr = (qd * qd - (qq - aRadius * aRadius));
337 if( discriminantsqr < FLT_EPSILON )
342 const float discriminant = std::sqrt( discriminantsqr );
343 const float t1 = ( -qd - discriminant );
344 const float t2 = ( -qd + discriminant );
346 if( ( ( t1 < 0.0f ) || ( t1 >
m_Length ) ) && ( ( t2 < 0.0f ) || ( t2 >
m_Length ) ) )
356 *aOutNormalT0 = ( hitPointT1 - aCenter ) / aRadius;
357 *aOutNormalT1 = ( hitPointT2 - aCenter ) / aRadius;
float NextFloatDown(float v)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
bool IntersectSegment(const SFVEC2F &aStartA, const SFVEC2F &aEnd_minus_startA, const SFVEC2F &aStartB, const SFVEC2F &aEnd_minus_startB)
bool IntersectCircle(const SFVEC2F &aCenter, float aRadius, float *aOutT0, float *aOutT1, SFVEC2F *aOutNormalT0, SFVEC2F *aOutNormalT1) const
bool IntersectSegment(const SFVEC2F &aStart, const SFVEC2F &aEnd_minus_start, float *aOutT) const
float m_DOT_End_minus_start
dot( m_End_minus_start, m_End_minus_start)
float DistanceToPointSquared(const SFVEC2F &aPoint) const
SFVEC2F m_End_minus_start
SFVEC2F at(float t) const
RAYSEG2D(const SFVEC2F &s, const SFVEC2F &e)
void Init(const SFVEC3F &o, const SFVEC3F &d)
unsigned int m_dirIsNeg[3]
RAY_CLASSIFICATION m_Classification
bool IntersectSphere(const SFVEC3F &aCenter, float aRadius, float &aOutT0, float &aOutT1) const
unsigned int rayID
unique ray ID - not used - dummy