KiCad PCB EDA Suite
ray.h File Reference

Go to the source code of this file.

Classes

struct  RAY
 
struct  RAY2D
 
struct  RAYSEG2D
 

Enumerations

enum class  RAY_CLASSIFICATION {
  MMM , MMP , MPM , MPP ,
  PMM , PMP , PPM , PPP ,
  POO , MOO , OPO , OMO ,
  OOP , OOM , OMM , OMP ,
  OPM , OPP , MOM , MOP ,
  POM , POP , MMO , MPO ,
  PMO , PPO
}
 

Functions

bool IntersectSegment (const SFVEC2F &aStartA, const SFVEC2F &aEnd_minus_startA, const SFVEC2F &aStartB, const SFVEC2F &aEnd_minus_startB)
 

Enumeration Type Documentation

◆ RAY_CLASSIFICATION

enum class RAY_CLASSIFICATION
strong
Enumerator
MMM 
MMP 
MPM 
MPP 
PMM 
PMP 
PPM 
PPP 
POO 
MOO 
OPO 
OMO 
OOP 
OOM 
OMM 
OMP 
OPM 
OPP 
MOM 
MOP 
POM 
POP 
MMO 
MPO 
PMO 
PPO 

Definition at line 31 of file ray.h.

Function Documentation

◆ IntersectSegment()

bool IntersectSegment ( const SFVEC2F aStartA,
const SFVEC2F aEnd_minus_startA,
const SFVEC2F aStartB,
const SFVEC2F aEnd_minus_startB 
)

Definition at line 181 of file ray.cpp.

183{
184 float rxs = aEnd_minus_startA.x * aEnd_minus_startB.y - aEnd_minus_startA.y *
185 aEnd_minus_startB.x;
186
187 if( std::abs( rxs ) > glm::epsilon<float>() )
188 {
189 float inv_rxs = 1.0f / rxs;
190
191 SFVEC2F pq = aStartB - aStartA;
192
193 float t = ( pq.x * aEnd_minus_startB.y - pq.y * aEnd_minus_startB.x ) * inv_rxs;
194
195 if( ( t < 0.0f ) || ( t > 1.0f ) )
196 return false;
197
198 float u = ( pq.x * aEnd_minus_startA.y - pq.y * aEnd_minus_startA.x ) * inv_rxs;
199
200 if( ( u < 0.0f ) || ( u > 1.0f ) )
201 return false;
202
203 return true;
204 }
205
206 return false;
207}
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42

References std::abs().

Referenced by ROUND_SEGMENT_2D::Intersects().