codac 1.5.6
Loading...
Searching...
No Matches
codac2_geometry.h File Reference
Include dependency graph for codac2_geometry.h:

Go to the source code of this file.

Enumerations

enum class  codac2::OrientationInterval { }
 Enumeration representing feasible orientations. Can be used to assess an oriented angle, or the alignement of three points. More...
 

Functions

std::ostream & codac2::operator<< (std::ostream &os, const OrientationInterval &x)
 Streams out a OrientationInterval.
 
OrientationInterval codac2::orientation (const IntervalVector &p1, const IntervalVector &p2, const IntervalVector &p3)
 Computes the orientation of an ordered triplet of 2D points.
 
BoolInterval codac2::aligned (const IntervalVector &p1, const IntervalVector &p2, const IntervalVector &p3)
 Checks whether three 2D points are aligned (colinear).
 
std::vector< IntervalVector > codac2::convex_hull (std::vector< IntervalVector > pts)
 Computes the convex hull of a set of 2d points.
 

Detailed Description

Date
2024
Author
Simon Rohou
License: GNU Lesser General Public License (LGPL)

Enumeration Type Documentation

◆ OrientationInterval

enum class codac2::OrientationInterval
strong

Enumeration representing feasible orientations. Can be used to assess an oriented angle, or the alignement of three points.

The logical operator | can be used to combine OrientationInterval values.

Enumerator
UNKNOWN 

UNKNOWN: the orientation can be either clockwise, counter-clockwise, or aligned.

25 {
26 COLINEAR = 0x01,
27 CLOCKWISE = 0x02,
28 COUNTERCLOCKWISE = 0x04,
29 EMPTY = 0x00,
31 UNKNOWN = 0x01 | 0x02 | 0x04
32 };
@ UNKNOWN
Definition codac2_BoolInterval.h:29
@ EMPTY
Definition codac2_BoolInterval.h:27

Function Documentation

◆ operator<<()

std::ostream & codac2::operator<< ( std::ostream & os,
const OrientationInterval & x )
inline

Streams out a OrientationInterval.

Parameters
osThe stream to be updated
xThe orientation interval to stream out
Returns
A Reference to the updated stream
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 }
@ UNKNOWN
Definition codac2_geometry.h:31

◆ orientation()

OrientationInterval codac2::orientation ( const IntervalVector & p1,
const IntervalVector & p2,
const IntervalVector & p3 )

Computes the orientation of an ordered triplet of 2D points.

Determines whether the oriented angle \(\widehat{p_1 p_2 p_3}\) is positive (counterclockwise), negative (clockwise), or if the points are colinear (flat or 0 angle). Depending on floating point uncertainties, the test may not be able to conclude (a UNKNOWN value would then be returned).

Parameters
p1First point (2d IntervalVector) of the triplet.
p2Second point (2d IntervalVector) of the triplet (vertex of the angle).
p3Third point (2d IntervalVector) of the triplet.
Returns
An orientation of type OrientationInterval

◆ aligned()

BoolInterval codac2::aligned ( const IntervalVector & p1,
const IntervalVector & p2,
const IntervalVector & p3 )

Checks whether three 2D points are aligned (colinear).

Determines if the points lie on the same straight line using an orientation test (cross product). Depending on floating point uncertainties, the test may not be able to conclude (a UNKNOWN value would then be returned).

Parameters
p1First point (2d IntervalVector) of the triplet.
p2Second point (2d IntervalVector) of the triplet.
p3Third point (2d IntervalVector) of the triplet.
Returns
A BooleanInterval

◆ convex_hull()

std::vector< IntervalVector > codac2::convex_hull ( std::vector< IntervalVector > pts)

Computes the convex hull of a set of 2d points.

Given a set of 2d points enclosed in tiny boxes, the function computes their convex hull. The method is based on a Graham scan algorithm. The output list of the algorithm is a subset of the input list, with same uncertainties and a possible different order.

Parameters
pts2d points in any order
Returns
Points on the convex hull in counterclockwise order.