next up previous contents index
Next: Iso-oriented Rectangles ( rectangle Up: Basic Data Types for Previous: Generalized Polygons ( GEN_POLYGON   Contents   Index


Triangles ( triangle )

Definition

An instance t of the data type triangle is an oriented triangle in the two-dimensional plane. A triangle splits the plane into one bounded and one unbounded region. If the triangle 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. A triangle t is called degenerate, if the 3 vertices of t are collinear.

#include < LEDA/geo/triangle.h >

Types

triangle::coord_type the coordinate type (double).

triangle::point_type the point type (point).

Creation

triangle t introduces a variable t of type triangle. t is initialized to the empty triangle.

triangle t(const point& p, const point& q, const point& r)
    introduces a variable t of type triangle. t is initialized to the triangle [p, q, r].

triangle t(double x1, double y1, double x2, double y2, double x3, double y3)
    introduces a variable t of type triangle. t is initialized to the triangle [(x1, y1),(x2, y2),(x3, y3)].

Operations

point t.point1() returns the first vertex of triangle t.

point t.point2() returns the second vertex of triangle t.

point t.point3() returns the third vertex of triangle t.

point t[int i] returns the i-th vertex of t. Precondition 1 < = i < = 3.

int t.orientation() returns the orientation of t.

double 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 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 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 point& p) returns true, if p lies to the left of t.

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

bool t.on_boundary(const point& p)
    decides whether p lies on the boundary of t.

bool t.contains(const point& p)
    decides whether t contains p.

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

bool t.intersection(const segment& s)
    decides whether the bounded region or the boundary of t and s intersect.

triangle t.translate(double dx, double dy)
    returns t translated by vector (dx, dy).

triangle t.translate(const vector& v)
    returns t + v, i.e., t translated by vector v.
Precondition v.dim() = 2.

triangle t + const vector& v returns t translated by vector v.

triangle t - const vector& v returns t translated by vector - v.

triangle t.rotate(const point& q, double a)
    returns t rotated about point q by angle a.

triangle t.rotate(double alpha) returns t.rotate(t.point1(), alpha).

triangle t.rotate90(const 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.

triangle t.rotate90(int i=1) returns t.rotate90(t.source(),i).

triangle t.reflect(const point& p, const point& q)
    returns t reflected across the straight line passing through p and q.

triangle t.reflect(const point& p) returns t reflected across point p.

triangle t.reverse() returns t reversed.


next up previous contents index
Next: Iso-oriented Rectangles ( rectangle Up: Basic Data Types for Previous: Generalized Polygons ( GEN_POLYGON   Contents   Index
root 2008-01-09