Effective implementation of algorithms (Master Thesis)
Effective and error-free implementation of algorithms
|
Classes | |
class | ConvexHull |
struct | LineSegment |
class | Point |
Enumerations | |
enum | Quadrant { CENTER = 0, TOP_RIGHT = 1, TOP_LEFT = 2, BOTTOM_LEFT = 3, BOTTOM_RIGHT = 4 } |
enum | IntersectType { NO_INTERSECT, INTERSECT, TANGENCY, OVERLAY } |
Functions | |
template<typename T > | |
Quadrant | getQuadrant (const Point< T > point) |
template<typename T > | |
bool | angleLess (const Point< T > point1, const Point< T > point2) |
template<typename T > | |
T | sqrDistancePointPoint (Point< T > p1, Point< T > p2) |
template<typename T > | |
long double | distancePointPoint (Point< T > p1, Point< T > p2) |
template<typename T > | |
math::rational::Rational< T > | sqrDistancePointLine (Point< T > p, LineSegment< T > line) |
template<typename T > | |
long double | distancePointLine (Point< T > p, LineSegment< T > line) |
template<typename T > | |
math::rational::Rational< T > | sqrDistancePointLineSegment (Point< T > p, LineSegment< T > line) |
template<typename T > | |
long double | distancePointLineSegment (Point< T > p, LineSegment< T > line) |
template<typename T > | |
bool | pointOnLine (Point< T > p, LineSegment< T > s) |
template<typename T > | |
bool | pointOnLineSegment (Point< T > p, LineSegment< T > s, bool acceptCorners) |
template<typename T > | |
IntersectType | intervalIntersect (T a1, T a2, T b1, T b2) |
template<typename T > | |
IntersectType | intersectLineLineSegment (const LineSegment< T > &line, const LineSegment< T > &segment) |
template<typename T > | |
IntersectType | intersectLineSegmentLineSegment (const LineSegment< T > &segment1, const LineSegment< T > &segment2) |
template<typename T > | |
bool | operator== (const Point< T > &a, const Point< T > &b) |
template<typename T > | |
bool | operator!= (const Point< T > &a, const Point< T > &b) |
template<typename T > | |
Point< T > | operator+ (const Point< T > &a, const Point< T > &b) |
template<typename T > | |
Point< T > | operator- (const Point< T > &a, const Point< T > &b) |
template<typename T > | |
Point< T > | operator- (const Point< T > &a) |
template<typename T > | |
Point< T > | operator* (const Point< T > &a, T scalar) |
template<typename T > | |
Point< T > | operator/ (const Point< T > &a, T scalar) |
template<typename T > | |
int | signum (T n) |
Quadrant of an point
Note that quadrants are ordered with increasing angle starting with top right quadrant = 1
CENTER |
Point is in the center |
TOP_RIGHT |
Up right quadrant, including x-axis, excluding y-axis |
TOP_LEFT |
Up left quadrant, including y-axis, excluding x-axis |
BOTTOM_LEFT |
Down left quadrant, including x-axis, excluding y-axis |
BOTTOM_RIGHT |
Down right quadrant, including y-axis, excluding x-axis |
bool geometry::two_d::angleLess | ( | const Point< T > | point1, |
const Point< T > | point2 | ||
) |
Compare two vectors by angle with x-axis
long double geometry::two_d::distancePointLine | ( | Point< T > | p, |
LineSegment< T > | line | ||
) |
Calculate distance between point and line.
Note: We reuse code from sqrDistancePointLine() because we do not need to compute fraction value and the whole Rational class (and we won't have problems with overflows).
long double geometry::two_d::distancePointLineSegment | ( | Point< T > | p, |
LineSegment< T > | line | ||
) |
Calculate distance between point and line segment.
Note: We don't reuse sqrDistancePointPoint because this whole function can be calculated in long doubles and won't have problems with Rational overflows.
long double geometry::two_d::distancePointPoint | ( | Point< T > | p1, |
Point< T > | p2 | ||
) |
Calculate distance between two points
Quadrant geometry::two_d::getQuadrant | ( | const Point< T > | point | ) |
IntersectType geometry::two_d::intersectLineLineSegment | ( | const LineSegment< T > & | line, |
const LineSegment< T > & | segment | ||
) |
Determine whether line intersects with line segment. Warning: On integer types, be sure to compute this in double-sized type.
IntersectType geometry::two_d::intersectLineSegmentLineSegment | ( | const LineSegment< T > & | segment1, |
const LineSegment< T > & | segment2 | ||
) |
Determine whether two line segments intersects. Warning: On integer types, be sure to compute this in double-sized type.
IntersectType geometry::two_d::intervalIntersect | ( | T | a1, |
T | a2, | ||
T | b1, | ||
T | b2 | ||
) |
Determine whether two closed intervals intersects. Note that we allow any ordering on interval ranges;
bool geometry::two_d::operator!= | ( | const Point< T > & | a, |
const Point< T > & | b | ||
) |
Point<T> geometry::two_d::operator* | ( | const Point< T > & | a, |
T | scalar | ||
) |
Point<T> geometry::two_d::operator+ | ( | const Point< T > & | a, |
const Point< T > & | b | ||
) |
Point<T> geometry::two_d::operator- | ( | const Point< T > & | a | ) |
Point<T> geometry::two_d::operator- | ( | const Point< T > & | a, |
const Point< T > & | b | ||
) |
Point<T> geometry::two_d::operator/ | ( | const Point< T > & | a, |
T | scalar | ||
) |
bool geometry::two_d::operator== | ( | const Point< T > & | a, |
const Point< T > & | b | ||
) |
bool geometry::two_d::pointOnLine | ( | Point< T > | p, |
LineSegment< T > | s | ||
) |
Determine whether point lies on line. Warning: On float numbers use distanceToLineSegment instead and check for zero with epsilon error. Warning: On integer types, be sure to compute this in double-sized type.
bool geometry::two_d::pointOnLineSegment | ( | Point< T > | p, |
LineSegment< T > | s, | ||
bool | acceptCorners | ||
) |
Determine whether point lies on line. Warning: On float numbers use distanceToLineSegment instead and check for zero with epsilon error. Warning: On integer types, be sure to compute this in double-sized type.
int geometry::two_d::signum | ( | T | n | ) |
math::rational::Rational<T> geometry::two_d::sqrDistancePointLine | ( | Point< T > | p, |
LineSegment< T > | line | ||
) |
Calculate sqaure of distance between point and line.
math::rational::Rational<T> geometry::two_d::sqrDistancePointLineSegment | ( | Point< T > | p, |
LineSegment< T > | line | ||
) |
Calculate square of the distance between point and line segment.
T geometry::two_d::sqrDistancePointPoint | ( | Point< T > | p1, |
Point< T > | p2 | ||
) |
Calculate square of the distance between two points.