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

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

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

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

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

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

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

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

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

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

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

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