codac 1.5.6
Loading...
Searching...
No Matches
codac2_geometry.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "codac2_BoolInterval.h"
14
15namespace codac2
16{
25 {
26 COLINEAR = 0x01,
27 CLOCKWISE = 0x02,
28 COUNTERCLOCKWISE = 0x04,
29 EMPTY = 0x00,
31 UNKNOWN = 0x01 | 0x02 | 0x04
32 };
33
34 constexpr OrientationInterval operator|(OrientationInterval a, OrientationInterval b)
35 { return static_cast<OrientationInterval>(static_cast<int>(a) | static_cast<int>(b)); }
36
44 inline std::ostream& operator<<(std::ostream& os, const OrientationInterval& x)
45 {
46 if(x == OrientationInterval::EMPTY)
47 os << "[ empty ]";
48 else if(x == OrientationInterval::COLINEAR)
49 os << "[ col ]";
50 else if(x == OrientationInterval::CLOCKWISE)
51 os << "[ cw ]";
52 else if(x == OrientationInterval::COUNTERCLOCKWISE)
53 os << "[ ccw ]";
54 else if(x == (OrientationInterval::COLINEAR | OrientationInterval::CLOCKWISE))
55 os << "[ col, cw ]";
56 else if(x == (OrientationInterval::COLINEAR | OrientationInterval::COUNTERCLOCKWISE))
57 os << "[ col, ccw ]";
59 os << "[ col, cw, ccw ]";
60 return os;
61 }
62
77 OrientationInterval orientation(const IntervalVector& p1, const IntervalVector& p2, const IntervalVector& p3);
78
92 BoolInterval aligned(const IntervalVector& p1, const IntervalVector& p2, const IntervalVector& p3);
93
106 std::vector<IntervalVector> convex_hull(std::vector<IntervalVector> pts);
107}
std::ostream & operator<<(std::ostream &os, const BoolInterval &x)
Streams out a BoolInterval.
Definition codac2_BoolInterval.h:45
BoolInterval
Enumeration representing a boolean interval.
Definition codac2_BoolInterval.h:23
@ UNKNOWN
Definition codac2_BoolInterval.h:29
@ EMPTY
Definition codac2_BoolInterval.h:27
OrientationInterval
Enumeration representing feasible orientations. Can be used to assess an oriented angle,...
Definition codac2_geometry.h:25
@ UNKNOWN
Definition codac2_geometry.h:31
BoolInterval aligned(const IntervalVector &p1, const IntervalVector &p2, const IntervalVector &p3)
Checks whether three 2D points are aligned (colinear).
std::vector< IntervalVector > convex_hull(std::vector< IntervalVector > pts)
Computes the convex hull of a set of 2d points.
OrientationInterval orientation(const IntervalVector &p1, const IntervalVector &p2, const IntervalVector &p3)
Computes the orientation of an ordered triplet of 2D points.