60 Point(
double x,
double y) : x(x), y(y) {}
108 return sqrt(x * x + y * y);
122std::ostream& operator<<(std::ostream&,
const Point&);
135 }
else if (p1.y == p2.y) {
139 }
else if (p1.x == p2.x) {
141 throw std::runtime_error(
"Edge::Edge: p1 == p2");
163Point* GetPoint(
int index);
172void MarkConstrainedEdge(
int index);
173void MarkConstrainedEdge(
Edge& edge);
176int Index(
const Point* p);
177int EdgeIndex(
const Point* p1,
const Point* p2);
182bool GetConstrainedEdgeCCW(
const Point& p);
183bool GetConstrainedEdgeCW(
const Point& p);
184void SetConstrainedEdgeCCW(
const Point& p,
bool ce);
185void SetConstrainedEdgeCW(
const Point& p,
bool ce);
186bool GetDelunayEdgeCCW(
const Point& p);
187bool GetDelunayEdgeCW(
const Point& p);
188void SetDelunayEdgeCCW(
const Point& p,
bool e);
189void SetDelunayEdgeCW(
const Point& p,
bool e);
191bool Contains(
const Point* p);
192bool Contains(
const Edge& e);
194void Legalize(
Point& point);
200void ClearNeighbor(
const Triangle *triangle);
201void ClearNeighbors();
202void ClearDelunayEdges();
204inline bool IsInterior();
205inline void IsInterior(
bool b);
209bool CircumcicleContains(
const Point&)
const;
213bool IsCounterClockwise()
const;
224inline bool cmp(
const Point* a,
const Point* b)
228 }
else if (a->y == b->y) {
240 return Point(a.x + b.x, a.y + b.y);
246 return Point(a.x - b.x, a.y - b.y);
252 return Point(s * a.x, s * a.y);
255inline bool operator ==(
const Point& a,
const Point& b)
257 return a.x == b.x && a.y == b.y;
260inline bool operator !=(
const Point& a,
const Point& b)
262 return !(a.x == b.x) && !(a.y == b.y);
268 return a.x * b.x + a.y * b.y;
274 return a.x * b.y - a.y * b.x;
281 return Point(s * a.y, -s * a.x);
288 return Point(-s * a.y, s * a.x);
291inline Point* Triangle::GetPoint(
int index)
293 return points_[index];
296inline Triangle* Triangle::GetNeighbor(
int index)
298 return neighbors_[index];
301inline bool Triangle::Contains(
const Point* p)
303 return p == points_[0] || p == points_[1] || p == points_[2];
306inline bool Triangle::Contains(
const Edge& e)
308 return Contains(e.p) && Contains(e.q);
311inline bool Triangle::Contains(
const Point* p,
const Point* q)
313 return Contains(p) && Contains(q);
316inline bool Triangle::IsInterior()
321inline void Triangle::IsInterior(
bool b)
327bool IsDelaunay(
const std::vector<p2t::Triangle*>&);
bool constrained_edge[3]
Flags to determine if an edge is a Constrained edge.
Definition shapes.h:159
bool delaunay_edge[3]
Flags to determine if an edge is a Delauney edge.
Definition shapes.h:161
void Clear()
Clears all references to all other triangles and points.
Definition shapes.cpp:82
Sweep-line, Constrained Delauney Triangulation (CDT) See: Domiter, V.
Definition shapes.cpp:36
Point operator*(double s, const Point &a)
Multiply point by scalar.
Definition shapes.h:250
double Dot(const Point &a, const Point &b)
Peform the dot product on two vectors.
Definition shapes.h:266
Point operator+(const Point &a, const Point &b)
Add two points_ component-wise.
Definition shapes.h:238
bool IsDelaunay(const std::vector< p2t::Triangle * > &triangles)
Is this set a valid delaunay triangulation?
Definition shapes.cpp:392
Point operator-(const Point &a, const Point &b)
Subtract two points_ component-wise.
Definition shapes.h:244
double Cross(const Point &a, const Point &b)
Perform the cross product on two vectors. In 2D this produces a scalar.
Definition shapes.h:272
Edge(Point &p1, Point &p2)
Constructor.
Definition shapes.h:130
double Length() const
Get the length of this point (the norm).
Definition shapes.h:106
Point operator-() const
Negate this point.
Definition shapes.h:77
void operator+=(const Point &v)
Add a point to this point.
Definition shapes.h:85
std::vector< Edge * > edge_list
The edges this point constitutes an upper ending point.
Definition shapes.h:57
Point(double x, double y)
Construct using coordinates.
Definition shapes.h:60
void operator-=(const Point &v)
Subtract a point from this point.
Definition shapes.h:92
Point()
Default constructor does nothing (for performance).
Definition shapes.h:50
void operator*=(double a)
Multiply this point by a scalar.
Definition shapes.h:99
void set(double x_, double y_)
Set this point to some specified coordinates.
Definition shapes.h:70
void set_zero()
Set this point to all zeros.
Definition shapes.h:63
double Normalize()
Convert this point into a unit point. Returns the Length.
Definition shapes.h:112