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  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

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 36 of file ray.h.

37 {
38  MMM, MMP, MPM, MPP, PMM, PMP, PPM, PPP, POO, MOO, OPO, OMO, OOP, OOM, OMM,
40 };
Definition: ray.h:38
Definition: ray.h:38
Definition: ray.h:38
Definition: ray.h:39
Definition: ray.h:38
Definition: ray.h:38
Definition: ray.h:39
Definition: ray.h:39
Definition: ray.h:39
Definition: ray.h:39
Definition: ray.h:38
Definition: ray.h:38
Definition: ray.h:39
Definition: ray.h:38
Definition: ray.h:39
Definition: ray.h:38
Definition: ray.h:39
Definition: ray.h:38
Definition: ray.h:39
Definition: ray.h:39
Definition: ray.h:38
Definition: ray.h:38
Definition: ray.h:38
Definition: ray.h:38
Definition: ray.h:39
Definition: ray.h:38

Function Documentation

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.

Referenced by CROUNDSEGMENT2D::Intersects().

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