Navigation: Up, Table of Contents, Bibliography, Index, Title Page

Elementary 2D objects

The two-dimensional kernel classes are parameterized by a representation class. Before you can declare one of the following classes, you have to include at least one of the following two statements:

#include <CGAL/Cartesian.h>
#include < CGAL/Homogeneous.h>

CGAL provides points, vectors, and directions. A point is a point in the two-dimensional Euclidean plane E2, a vector is the difference of two points p2, p1 and denotes the direction and the distance from p1 to p2 in the vector space R2, and a direction represents

the family of vectors that are positive multiples of each other. Their interface is described in Chapter reference arrow.

CGAL_Point_2<R>
CGAL_Vector_2<R>
CGAL_Direction_2<R>

Lines in CGAL are directed, that is, they induce a partition of the plane into a positive side and a negative side. Any two points on a line induce an orientation of this line. A ray is semi-infinite interval on a line, and this line is oriented from the finite endpoint of this interval towards any other point in this interval. A segment is a bounded interval on a directed line, and the endpoints are ordered so that they induce the same direction as that of the line. Their interface is described in Chapter reference arrow.

CGAL_Line_2<R>
CGAL_Ray_2<R>
CGAL_Segment_2<R>

Next we introduce triangles and iso-oriented rectangles. More complex polygons can be obtained from the basic library (CGAL_Polygon_2 ), so they are not part of the kernel. In the same category, we introduce circles in the plane. As with any Jordan curves, triangles, iso-oriented rectangles and circles separate the plane into two regions, one bounded and one unbounded. Their interface is described in the Chapters reference arrow, reference arrow, and reference arrow.

CGAL_Triangle_2<R>
CGAL_Iso_rectangle_2<R>
CGAL_Circle_2<R>

Predicates and functions

For testing where a point p lies with respect to the line defined by two points q and r, one may be tempted to construct the line CGAL_Line_2<R>(q,r) and use the function call oriented_side(p). Pays off if many tests with respect to the line are made. Nevertheless, unless the number type is exact, the constructed line is only approximated, and round-off errors may lead oriented_side(p) to return an orientation which is different from the orientation of p, q, and r. This is the well-known problem of robustness.

In CGAL, we provide predicates in which such geometric decisions are made directly with a reference to the input points p, q, r, without an intermediary object like a line. This enables to use exact predicates that are cheaper than exact number types, a concept that has been the focus of much research recently in computational geometry. For the above test, the recommended way to get the result is to use CGAL_orientation(p,q,r).

Consequently, we propose the most common predicates in Chapter reference arrow. They use the elementary classes of the 2D kernel.

Affine transformations allow to generate new object instances under arbitrary affine transformations. These transformations include translations, rotations and scaling. Most of the classes above have a member function transform(CGAL_Aff_transformation t) which applies the transformation to the object instance. The interface of the transformation class is described in Chapter reference arrow.

CGAL_Aff_transformation_2<R>

CGAL also provides a set of functions that detect or compute the intersection between any two objects of the 2D kernel, and calculate their squared distance. These functions and their input types are described in Chapters reference arrow and reference arrow.


Return to chapter: The 2D Kernel: an Overview
Navigation: Up, Table of Contents, Bibliography, Index, Title Page
The CGAL Project. Wed, January 20, 1999.