next up previous contents index
Next: Geometry Algorithms ( geo_alg Up: Basic Data Types for Previous: Rational Circles ( rat_circle

     
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/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(rat_point p, rat_point q, rat_point r)
    introduces a variable t of type rat_triangle. t is initialized to the triangle [p, q, r].

rat_triangle t(rational x1, rational y1, rational x2, rational y2, rational x3, 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(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(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(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(rat_point p) returns true, if p lies to the left of t.

bool  t.outside(rat_point p) returns true, if p lies to the right of t.

bool  t.on_boundary(rat_point p)
    decides whether p lies on the boundary of t.

bool  t.contains(rat_point p) decides whether t contains p.

bool  t.intersection(rat_line l)
    decides whether the bounded region or the boundary of t and l intersect.

bool  t.intersection(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(rat_vector v) returns t + v, i.e., t translated by vector v.
Precondition v.dim() = 2.

rat_triangle t + rat_vector v returns t translated by vector v.

rat_triangle t - rat_vector v returns t translated by vector - v.

rat_triangle  t.rotate90(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(rat_point p, rat_point q)
    returns t reflected across the straight line passing through p and q.

rat_triangle  t.reflect(rat_point p) returns t reflected across point p.

rat_triangle  t.reverse() returns t reversed.


next up previous contents index
Next: Geometry Algorithms ( geo_alg Up: Basic Data Types for Previous: Rational Circles ( rat_circle

© Copyright 1995-2002, Algorithmic Solutions Software GmbH. All rights reserved.
2002-10-16