Effective implementation of algorithms (Master Thesis)
Effective and error-free implementation of algorithms
geometry::two_d Namespace Reference

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 >
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)

Enumeration Type Documentation

Enumerator:
NO_INTERSECT 
INTERSECT 
TANGENCY 
OVERLAY 

Quadrant of an point

Note that quadrants are ordered with increasing angle starting with top right quadrant = 1

Enumerator:
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


Function Documentation

template<typename T >
bool geometry::two_d::angleLess ( const Point< T >  point1,
const Point< T >  point2 
)

Compare two vectors by angle with x-axis

Returns:
true if angle of the first vector is less than angle of the second
template<typename T >
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).

Returns:
distance
template<typename T >
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.

Returns:
distance
template<typename T >
long double geometry::two_d::distancePointPoint ( Point< T >  p1,
Point< T >  p2 
)

Calculate distance between two points

Returns:
distance
template<typename T >
Quadrant geometry::two_d::getQuadrant ( const Point< T >  point)
template<typename T >
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.

template<typename T >
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.

template<typename T >
IntersectType geometry::two_d::intervalIntersect ( a1,
a2,
b1,
b2 
)

Determine whether two closed intervals intersects. Note that we allow any ordering on interval ranges;

template<typename T >
bool geometry::two_d::operator!= ( const Point< T > &  a,
const Point< T > &  b 
)
template<typename T >
Point<T> geometry::two_d::operator* ( const Point< T > &  a,
scalar 
)
template<typename T >
Point<T> geometry::two_d::operator+ ( const Point< T > &  a,
const Point< T > &  b 
)
template<typename T >
Point<T> geometry::two_d::operator- ( const Point< T > &  a)
template<typename T >
Point<T> geometry::two_d::operator- ( const Point< T > &  a,
const Point< T > &  b 
)
template<typename T >
Point<T> geometry::two_d::operator/ ( const Point< T > &  a,
scalar 
)
template<typename T >
bool geometry::two_d::operator== ( const Point< T > &  a,
const Point< T > &  b 
)
template<typename T >
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.

template<typename T >
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.

template<typename T >
int geometry::two_d::signum ( n)
template<typename T >
math::rational::Rational<T> geometry::two_d::sqrDistancePointLine ( Point< T >  p,
LineSegment< T >  line 
)

Calculate sqaure of distance between point and line.

Returns:
square of the distance
template<typename T >
math::rational::Rational<T> geometry::two_d::sqrDistancePointLineSegment ( Point< T >  p,
LineSegment< T >  line 
)

Calculate square of the distance between point and line segment.

Returns:
square of the distance
template<typename T >
T geometry::two_d::sqrDistancePointPoint ( Point< T >  p1,
Point< T >  p2 
)

Calculate square of the distance between two points.

Returns:
square of the distance.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines