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 , a vector is the difference
of two points , and denotes the direction and the distance from
to in the vector space , and a direction represents
the family of vectors that are positive multiples of each other.
Their interface is described in Chapter
.
Point_2<R>
Vector_2<R>
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
.
Line_2<R>
Ray_2<R>
Segment_2<R>
Next we introduce triangles and iso-oriented rectangles.
More complex polygons can be obtained from the basic library
(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
,
, and
.
Triangle_2<R>
Iso_rectangle_2<R>
Circle_2<R>
For testing where a point lies with respect to the line defined by two points and , one may be tempted to construct the line 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 , , and . 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 , , , 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 orientation(p,q,r).
Consequently, we propose the most common predicates in
Chapter
. 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(Aff_transformation t) which applies the transformation to
the object instance. The interface of the transformation class is described
in Chapter
.
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
and
.