KiCad PCB EDA Suite
p2t Namespace Reference

Sweep-line, Constrained Delauney Triangulation (CDT) See: Domiter, V. More...

Classes

class  AdvancingFront
 
class  CDT
 
struct  Edge
 
struct  Node
 
struct  Point
 
class  Sweep
 
class  SweepContext
 
class  Triangle
 

Enumerations

enum  Orientation { CW, CCW, COLLINEAR }
 

Functions

bool cmp (const Point *a, const Point *b)
 
Point operator+ (const Point &a, const Point &b)
 Add two points_ component-wise. More...
 
Point operator- (const Point &a, const Point &b)
 Subtract two points_ component-wise. More...
 
Point operator* (double s, const Point &a)
 Multiply point by scalar. More...
 
bool operator== (const Point &a, const Point &b)
 
bool operator!= (const Point &a, const Point &b)
 
double Dot (const Point &a, const Point &b)
 Peform the dot product on two vectors. More...
 
double Cross (const Point &a, const Point &b)
 Perform the cross product on two vectors. In 2D this produces a scalar. More...
 
Point Cross (const Point &a, double s)
 Perform the cross product on a point and a scalar. More...
 
Point Cross (const double s, const Point &a)
 Perform the cross product on a scalar and a point. More...
 
Orientation Orient2d (Point &pa, Point &pb, Point &pc)
 Forumla to calculate signed area
Positive if CCW
Negative if CW
0 if collinear
More...
 
bool InScanArea (Point &pa, Point &pb, Point &pc, Point &pd)
 

Variables

const double PI_3div4 = 3 * M_PI / 4
 
const double PI_div2 = 1.57079632679489661923
 
const double EPSILON = 1e-12
 
const double kAlpha = 0.3
 

Detailed Description

Sweep-line, Constrained Delauney Triangulation (CDT) See: Domiter, V.

Author
Mason Green mason.nosp@m..gre.nosp@m.en@gm.nosp@m.ail..nosp@m.com

and Zalik, B.(2008)'Sweep-line algorithm for constrained Delaunay triangulation', International Journal of Geographical Information Science

"FlipScan" Constrained Edge Algorithm invented by Thomas ┼hlÚn, thahl.nosp@m.en@g.nosp@m.mail..nosp@m.com

Enumeration Type Documentation

Enumerator
CW 
CCW 
COLLINEAR 

Definition at line 46 of file polygon/poly2tri/common/utils.h.

Function Documentation

bool p2t::cmp ( const Point a,
const Point b 
)
inline

Definition at line 227 of file shapes.h.

References p2t::Point::x, and p2t::Point::y.

Referenced by SCH_EDIT_FRAME::addCurrentItemToList(), PCB_EDIT_FRAME::RecreateBOMFileFromBoard(), and TrackListSortByNetcode().

228 {
229  if( a->y < b->y )
230  {
231  return true;
232  }
233  else if( a->y == b->y )
234  {
235  // Make sure q is point with greater x value
236  if( a->x < b->x )
237  {
238  return true;
239  }
240  }
241 
242  return false;
243 }
double p2t::Cross ( const Point a,
const Point b 
)
inline

Perform the cross product on two vectors. In 2D this produces a scalar.

Definition at line 287 of file shapes.h.

References p2t::Point::x, and p2t::Point::y.

Referenced by SEG::Side().

288 {
289  return a.x * b.y - a.y * b.x;
290 }
Point p2t::Cross ( const Point a,
double  s 
)
inline

Perform the cross product on a point and a scalar.

In 2D this produces a point.

Definition at line 295 of file shapes.h.

References p2t::Point::x, and p2t::Point::y.

296 {
297  return Point( s * a.y, -s * a.x );
298 }
Point p2t::Cross ( const double  s,
const Point a 
)
inline

Perform the cross product on a scalar and a point.

In 2D this produces a point.

Definition at line 303 of file shapes.h.

References p2t::Point::x, and p2t::Point::y.

304 {
305  return Point( -s * a.y, s * a.x );
306 }
double p2t::Dot ( const Point a,
const Point b 
)
inline

Peform the dot product on two vectors.

Definition at line 280 of file shapes.h.

References p2t::Point::x, and p2t::Point::y.

281 {
282  return a.x * b.x + a.y * b.y;
283 }
bool p2t::InScanArea ( Point pa,
Point pb,
Point pc,
Point pd 
)

Definition at line 113 of file polygon/poly2tri/common/utils.h.

References p2t::Point::x, and p2t::Point::y.

114 {
115  double oadb = (pa.x - pb.x) * (pd.y - pb.y) - (pd.x - pb.x) * (pa.y - pb.y);
116 
117  if( oadb >= -EPSILON )
118  {
119  return false;
120  }
121 
122  double oadc = (pa.x - pc.x) * (pd.y - pc.y) - (pd.x - pc.x) * (pa.y - pc.y);
123 
124  if( oadc <= EPSILON )
125  {
126  return false;
127  }
128 
129  return true;
130 }
const double EPSILON
bool p2t::operator!= ( const Point a,
const Point b 
)
inline

Definition at line 273 of file shapes.h.

References p2t::Point::x, and p2t::Point::y.

274 {
275  return !(a.x == b.x) && !(a.y == b.y);
276 }
Point p2t::operator* ( double  s,
const Point a 
)
inline

Multiply point by scalar.

Definition at line 261 of file shapes.h.

References p2t::Point::x, and p2t::Point::y.

262 {
263  return Point( s * a.x, s * a.y );
264 }
Point p2t::operator+ ( const Point a,
const Point b 
)
inline

Add two points_ component-wise.

Definition at line 247 of file shapes.h.

References p2t::Point::x, and p2t::Point::y.

248 {
249  return Point( a.x + b.x, a.y + b.y );
250 }
Point p2t::operator- ( const Point a,
const Point b 
)
inline

Subtract two points_ component-wise.

Definition at line 254 of file shapes.h.

References p2t::Point::x, and p2t::Point::y.

255 {
256  return Point( a.x - b.x, a.y - b.y );
257 }
bool p2t::operator== ( const Point a,
const Point b 
)
inline

Definition at line 267 of file shapes.h.

References p2t::Point::x, and p2t::Point::y.

268 {
269  return a.x == b.x && a.y == b.y;
270 }
Orientation p2t::Orient2d ( Point pa,
Point pb,
Point pc 
)

Forumla to calculate signed area
Positive if CCW
Negative if CW
0 if collinear

A[P1,P2,P3]  =  (x1*y2 - y1*x2) + (x2*y3 - y2*x3) + (x3*y1 - y3*x1)
             =  (x1-x3)*(y2-y3) - (y1-y3)*(x2-x3)

Definition at line 60 of file polygon/poly2tri/common/utils.h.

References CCW, COLLINEAR, CW, p2t::Point::x, and p2t::Point::y.

61 {
62  double detleft = (pa.x - pc.x) * (pb.y - pc.y);
63  double detright = (pa.y - pc.y) * (pb.x - pc.x);
64  double val = detleft - detright;
65 
66  if( val > -EPSILON && val < EPSILON )
67  {
68  return COLLINEAR;
69  }
70  else if( val > 0 )
71  {
72  return CCW;
73  }
74 
75  return CW;
76 }
const double EPSILON

Variable Documentation

const double p2t::EPSILON = 1e-12

Definition at line 44 of file polygon/poly2tri/common/utils.h.

const double p2t::kAlpha = 0.3

Definition at line 42 of file sweep_context.h.

const double p2t::PI_3div4 = 3 * M_PI / 4

Definition at line 42 of file polygon/poly2tri/common/utils.h.

const double p2t::PI_div2 = 1.57079632679489661923

Definition at line 43 of file polygon/poly2tri/common/utils.h.