1 #ifndef GEOM_H_INCLUDED
2 #define GEOM_H_INCLUDED
56 static std::tuple<double, double, double>
57 CircumCircle(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3);
63 const std::array<double, 3>& v1,
const std::array<double, 3>& v2,
64 const std::array<double, 3>& v3,
const std::array<double, 3>& v4)
66 const double denom = (v4[1] - v3[1]) * (v2[0] - v1[0]) - (v4[0] - v3[0]) * (v2[1] - v1[1]);
67 const double ua = ((v4[0] - v3[0]) * (v1[1] - v3[1]) - (v4[1] - v3[1]) * (v1[0] - v3[0])) / denom;
68 return v1 + ua * (v2 - v1);
77 isLeft(
const std::array<double, 3>& P0,
const std::array<double, 3>& P1,
const std::array<double, 3>& P2 )
79 return (P1[0] - P0[0])*(P2[1] - P0[1]) - (P2[0] - P0[0])*(P1[1] - P0[1]);
90 wn_PnPoly(
const std::array<double, 3>& p,
const std::vector<Node*>& nodes)
100 array<double, 3> e_a = *(*it);
101 array<double, 3> e_b = *(*
next(it));
103 if (e_a[1] <= p[1]) {
105 if (isLeft( e_a, e_b, p) > 0) {
110 if (e_b[1] <= p[1]) {
111 if (isLeft( e_a, e_b, p) < 0) {
117 }
while(++it != nodes.begin());
124 #endif // end-of-include-guard
Namespace for miscellaneous utilities.
static int isLeft(const std::array< double, 3 > &P0, const std::array< double, 3 > &P1, const std::array< double, 3 > &P2)
IsLeft tests if a point is Left|On|Right of an infinite line.
Namespace for the core simulator.
Namespace for container related classes.
static std::array< double, 3 > Intersection(const std::array< double, 3 > &v1, const std::array< double, 3 > &v2, const std::array< double, 3 > &v3, const std::array< double, 3 > &v4)
Intersection of two lines in x-y plane.s.
ConstCircularIterator class and helper functions.
Extending std with arithmetic for std::array.
CircularIterator< T > next(CircularIterator< T > i)
Helper yields the position the iterator would have if moved forward (in circular fashion) by 1 positi...
ConstCircularIterator< typename T::const_iterator > make_const_circular(const T &c)
Helper produces const circular iterator whose range corresponds to the begin and end iterators of a c...
static int wn_PnPoly(const std::array< double, 3 > &p, const std::vector< Node * > &nodes)
Calculates winding number to test whether a point is inside polygon (wn=0 iff p outside).
Provides geometric functions.
CircularIterator class and helper functions.