CGAL::Triangle_2<Kernel>

Definition

An object t of the class Triangle_2<Kernel> is a triangle in the two-dimensional Euclidean plane  2. Triangle t is oriented, i.e., its boundary has clockwise or counterclockwise orientation. We call the side to the left of the boundary the positive side and the side to the right of the boundary the negative side.

The boundary of a triangle splits the plane in two open regions, a bounded one and an unbounded one.

Creation

Triangle_2<Kernel> t ( Point_2<Kernel> p, Point_2<Kernel> q, Point_2<Kernel> r);
introduces a triangle t with vertices p, q and r.

Operations

bool t.operator== ( t2) Test for equality: two triangles are equal, iff there exists a cyclic permutation of the vertices of t2, such that they are equal to the vertices of t.

bool t.operator!= ( t2) Test for inequality.

Point_2<Kernel> t.vertex ( int i) returns the i'th vertex modulo 3 of t.

Point_2<Kernel> t.operator[] ( int i) returns vertex(i).

Predicates

bool t.is_degenerate () triangle t is degenerate, if the vertices are collinear.

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

Oriented_side t.oriented_side ( Point_2<Kernel> p)
returns ON_ORIENTED_BOUNDARY, or POSITIVE_SIDE, or the constant ON_NEGATIVE_SIDE, determined by the position of point p.
Precondition: t is not degenerate.

Bounded_side t.bounded_side ( Point_2<Kernel> p)
returns the constant ON_BOUNDARY, ON_BOUNDED_SIDE, or else ON_UNBOUNDED_SIDE, depending on where point p is.
Precondition: t is not degenerate.

For convenience we provide the following Boolean functions:

bool t.has_on_positive_side ( Point_2<Kernel> p)
bool t.has_on_negative_side ( Point_2<Kernel> p)
bool t.has_on_boundary ( Point_2<Kernel> p)
bool t.has_on_bounded_side ( Point_2<Kernel> p)
bool t.has_on_unbounded_side ( Point_2<Kernel> p)
Precondition: t is not degenerate.

Miscellaneous

Triangle_2<Kernel> t.opposite () returns a triangle where the boundary is oriented the other way round (this flips the positive and the negative side, but not the bounded and unbounded side).

Kernel::FT t.area () returns the signed area of t.

Bbox_2 t.bbox () returns a bounding box containing t.

Triangle_2<Kernel> t.transform ( Aff_transformation_2<Kernel> at)
returns the triangle obtained by applying at on the three vertices of t.

See Also

Kernel::Triangle_2