     Next: Iso-oriented Rational Rectangles ( Up: Basic Data Types for Previous: Rational Circles ( rat_circle   Contents   Index

# Rational Triangles ( rat_triangle )

Definition

An instance t of the data type rat_triangle is an oriented triangle in the two-dimensional plane with rational coordinates. A rat_triangle t splits the plane into one bounded and one unbounded region. If t is positively oriented, the bounded region is to the left of it, if it is negatively oriented, the unbounded region is to the left of it. t is called degenerate, if the 3 vertices of t are collinear.

#include < LEDA/geo/rat_triangle.h >

Types

 rat_triangle::coord_type the coordinate type (rational). rat_triangle::point_type the point type (rat_point).

Creation

 rat_triangle t introduces a variable t of type rat_triangle. t is initialized to the empty triangle. rat_triangle t(const rat_point& p, const rat_point& q, const rat_point& r) introduces a variable t of type rat_triangle. t is initialized to the triangle [p, q, r]. rat_triangle t(const rational& x1, const rational& y1, const rational& x2, const rational& y2, const rational& x3, const rational& y3) introduces a variable t of type rat_triangle. t is initialized to the triangle [(x1, y1),(x2, y2),(x3, y3)]. rat_triangle t(const triangle& t, int prec = rat_point::default_precision) introduces a variable t of type rat_triangle. t is initialized to the triangle obtained by approximating the three defining points of t.

Operations

 void t.normalize() simplifies the homogenous representation by calling p.normalize() for every vertex of t. rat_point t.point1() returns the first vertex of triangle t. rat_point t.point2() returns the second vertex of triangle t. rat_point t.point3() returns the third vertex of triangle t. rat_point t[int i] returns the i-th vertex of t. Precondition 1 < = i < = 3. int t.orientation() returns the orientation of t. rational t.area() returns the signed area of t (positive, if orientation(a, b, c) > 0, negative otherwise). bool t.is_degenerate() returns true if the vertices of t are collinear. int t.side_of(const rat_point& p) returns +1 if p lies to the left of t, 0 if p lies on t and -1 if p lies to the right of t. region_kind t.region_of(const rat_point& p) returns BOUNDED REGION if p lies in the bounded region of t, ON REGION if p lies on t and UNBOUNDED REGION if p lies in the unbounded region. bool t.inside(const rat_point& p) returns true, if p lies to the left of t. bool t.outside(const rat_point& p) returns true, if p lies to the right of t. bool t.on_boundary(const rat_point& p) decides whether p lies on the boundary of t. bool t.contains(const rat_point& p) decides whether t contains p. bool t.intersection(const rat_line& l) decides whether the bounded region or the boundary of t and l intersect. bool t.intersection(const rat_segment& s) decides whether the bounded region or the boundary of t and s intersect. rat_triangle t.translate(rational dx, rational dy) returns t translated by vector (dx, dy). rat_triangle t.translate(const rat_vector& v) returns t + v, i.e., t translated by vector v. Precondition v.dim() = 2. rat_triangle t + const rat_vector& v returns t translated by vector v. rat_triangle t - const rat_vector& v returns t translated by vector - v. rat_triangle t.rotate90(const rat_point& q, int i=1) returns t rotated about q by an angle of i x 90 degrees. If i > 0 the rotation is counter-clockwise otherwise it is clockwise. rat_triangle t.rotate90(int i=1) returns t.rotate90(t.source(),i). rat_triangle t.reflect(const rat_point& p, const rat_point& q) returns t reflected across the straight line passing through p and q. rat_triangle t.reflect(const rat_point& p) returns t reflected across point p. rat_triangle t.reverse() returns t reversed.     Next: Iso-oriented Rational Rectangles ( Up: Basic Data Types for Previous: Rational Circles ( rat_circle   Contents   Index