28 int right_intersect_count = 0;
29 for (
int i = 0; i <
length(); i++) {
32 if ( (to_check.
y() <
minimum(vert_1.
y(), vert_2.
y()))
33 || (to_check.
y() >
maximum(vert_1.
y(), vert_2.
y())) )
continue;
35 if (vert_2.
x() == vert_1.
x()) {
36 x_intersect = vert_2.
x();
38 double m = (vert_2.
y() - vert_1.
y()) / (vert_2.
x() - vert_1.
x());
39 x_intersect = 1.0 / m * (to_check.
y() - vert_1.
y() + m * vert_1.
x());
41 if (x_intersect > to_check.
x()) right_intersect_count++;
43 return !!(right_intersect_count % 2);
const geometric::cartesian_point & get(int index) const
Accesses individual objects stored in "this" at the "index" position.
int length() const
Returns the current reported length of the allocated C array.
Provides a geometric point that use double floating points numbers.
bool inside(const cartesian_point &to_check)
Returns true if the point "to_check" is inside of this polygon.
The guards collection helps in testing preconditions and reporting errors.
type maximum(type a, type b)
minimum returns the lesser of two values.
type minimum(type a, type b)
maximum returns the greater of two values.
Contains all of our objects for geometry and avoids name clashes.