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

# Real Triangles ( real_triangle )

Definition

An instance t of the data type real_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/real_triangle.h >

Types

 real_triangle::coord_type the coordinate type (real). real_triangle::point_type the point type (real_point).

Creation

 real_triangle t introduces a variable t of type real_triangle. t is initialized to the empty triangle. real_triangle t(const real_point& p, const real_point& q, const real_point& r) introduces a variable t of type real_triangle. t is initialized to the triangle [p, q, r]. real_triangle t(real x1, real y1, real x2, real y2, real x3, real y3) introduces a variable t of type real_triangle. t is initialized to the triangle [(x1, y1),(x2, y2),(x3, y3)]. real_triangle t(const triangle& t1, int prec = 0) introduces a variable t of type real_triangle initialized to the triangle t1. (The second argument is for compatibility with rat_triangle.) real_triangle t(const rat_triangle& t1) introduces a variable t of type real_triangle initialized to the triangle t1.

Operations

 real_point t.point1() returns the first vertex of triangle t. real_point t.point2() returns the second vertex of triangle t. real_point t.point3() returns the third vertex of triangle t. real_point t[int i] returns the i-th vertex of t. Precondition 1 < = i < = 3. int t.orientation() returns the orientation of t. real 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 real_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 real_point& p) returns BOUNDEDREGION if p lies in the bounded region of t, ONREGION if p lies on t and UNBOUNDEDREGION if p lies in the unbounded region. bool t.inside(const real_point& p) returns true, if p lies to the left of t. bool t.outside(const real_point& p) returns true, if p lies to the right of t. bool t.on_boundary(const real_point& p) decides whether p lies on the boundary of t. bool t.contains(const real_point& p) decides whether t contains p. bool t.intersection(const real_line& l) decides whether the bounded region or the boundary of t and l intersect. bool t.intersection(const real_segment& s) decides whether the bounded region or the boundary of t and s intersect. real_triangle t.translate(real dx, real dy) returns t translated by vector (dx, dy). real_triangle t.translate(const real_vector& v) returns t + v, i.e., t translated by vector v. Precondition v.dim() = 2. real_triangle t + const real_vector& v returns t translated by vector v. real_triangle t - const real_vector& v returns t translated by vector - v. real_triangle t.rotate90(const real_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. real_triangle t.rotate90(int i=1) returns t.rotate90(t.source(),i). real_triangle t.reflect(const real_point& p, const real_point& q) returns t reflected across the straight line passing through p and q. real_triangle t.reflect(const real_point& p) returns t reflected across point p. real_triangle t.reverse() returns t reversed.

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