60 Point(
double x,
double y) : x(x), y(y) {}
70 void set(
double x_,
double y_)
108 return sqrt(x * x + y * y);
114 const double len =
Length();
133 }
else if (p1.y == p2.y) {
137 }
else if (p1.x == p2.x) {
161 Point* GetPoint(
int index);
170 void MarkConstrainedEdge(
int index);
171 void MarkConstrainedEdge(
Edge& edge);
174 int Index(
const Point* p);
175 int EdgeIndex(
const Point* p1,
const Point* p2);
179 bool GetConstrainedEdgeCCW(
const Point& p);
180 bool GetConstrainedEdgeCW(
const Point& p);
181 void SetConstrainedEdgeCCW(
const Point& p,
bool ce);
182 void SetConstrainedEdgeCW(
const Point& p,
bool ce);
183 bool GetDelunayEdgeCCW(
const Point& p);
184 bool GetDelunayEdgeCW(
const Point& p);
185 void SetDelunayEdgeCCW(
const Point& p,
bool e);
186 void SetDelunayEdgeCW(
const Point& p,
bool e);
188 bool Contains(
const Point* p);
189 bool Contains(
const Edge& e);
190 bool Contains(
const Point* p,
const Point* q);
191 void Legalize(
Point& point);
197 void ClearNeighbor(
const Triangle *triangle);
198 void ClearNeighbors();
199 void ClearDelunayEdges();
201 inline bool IsInterior();
202 inline void IsInterior(
bool b);
219 inline bool cmp(
const Point* a,
const Point* b)
223 }
else if (a->y == b->y) {
235 return Point(a.x + b.x, a.y + b.y);
241 return Point(a.x - b.x, a.y - b.y);
247 return Point(s * a.x, s * a.y);
250 inline bool operator ==(
const Point& a,
const Point& b)
252 return a.x == b.x && a.y == b.y;
255 inline bool operator !=(
const Point& a,
const Point& b)
257 return !(a.x == b.x) && !(a.y == b.y);
263 return a.x * b.x + a.y * b.y;
269 return a.x * b.y - a.y * b.x;
276 return Point(s * a.y, -s * a.x);
283 return Point(-s * a.y, s * a.x);
286 inline Point* Triangle::GetPoint(
int index)
288 return points_[index];
291 inline Triangle* Triangle::GetNeighbor(
int index)
293 return neighbors_[index];
296 inline bool Triangle::Contains(
const Point* p)
298 return p == points_[0] || p == points_[1] || p == points_[2];
301 inline bool Triangle::Contains(
const Edge& e)
303 return Contains(e.p) && Contains(e.q);
306 inline bool Triangle::Contains(
const Point* p,
const Point* q)
308 return Contains(p) && Contains(q);
311 inline bool Triangle::IsInterior()
316 inline void Triangle::IsInterior(
bool b)
double Length() const
Get the length of this point (the norm).
Definition: shapes.h:106
bool delaunay_edge[3]
Flags to determine if an edge is a Delauney edge.
Definition: shapes.h:159
Triangle(Point &a, Point &b, Point &c)
Constructor.
Definition: shapes.cpp:36
double Cross(const Point &a, const Point &b)
Perform the cross product on two vectors. In 2D this produces a scalar.
Definition: shapes.h:267
Sweep-line, Constrained Delauney Triangulation (CDT) See: Domiter, V.
Definition: shapes.cpp:34
Point operator+(const Point &a, const Point &b)
Add two points_ component-wise.
Definition: shapes.h:233
Edge(Point &p1, Point &p2)
Constructor.
Definition: shapes.h:128
bool constrained_edge[3]
Flags to determine if an edge is a Constrained edge.
Definition: shapes.h:157
double Normalize()
Convert this point into a unit point. Returns the Length.
Definition: shapes.h:112
std::vector< Edge * > edge_list
The edges this point constitutes an upper ending point.
Definition: shapes.h:57
void operator-=(const Point &v)
Subtract a point from this point.
Definition: shapes.h:92
void operator+=(const Point &v)
Add a point to this point.
Definition: shapes.h:85
Point operator-() const
Negate this point.
Definition: shapes.h:77
void set(double x_, double y_)
Set this point to some specified coordinates.
Definition: shapes.h:70
void operator*=(double a)
Multiply this point by a scalar.
Definition: shapes.h:99
Point()
Default constructor does nothing (for performance).
Definition: shapes.h:50
void Clear()
Clears all references to all other triangles and points.
Definition: shapes.cpp:76
Point(double x, double y)
Construct using coordinates.
Definition: shapes.h:60
Point operator*(double s, const Point &a)
Multiply point by scalar.
Definition: shapes.h:245
void set_zero()
Set this point to all zeros.
Definition: shapes.h:63
Point operator-(const Point &a, const Point &b)
Subtract two points_ component-wise.
Definition: shapes.h:239
double Dot(const Point &a, const Point &b)
Peform the dot product on two vectors.
Definition: shapes.h:261