Add Kernel_23

This commit is contained in:
Philipp Möller 2012-08-23 12:16:14 +00:00
parent b6ed6e766f
commit 56c1938a52
69 changed files with 19999 additions and 0 deletions

68
.gitattributes vendored
View File

@ -2374,6 +2374,74 @@ Jet_fitting_3/doc_tex/Jet_fitting_3_ref/Eigen_svd.tex -text
Jet_fitting_3/doc_tex/Jet_fitting_3_ref/template_dependence.jpg -text svneol=unset#image/jpeg
Jet_fitting_3/doc_tex/Jet_fitting_3_ref/template_dependence.pdf -text svneol=unset#application/pdf
Jet_fitting_3/examples/Jet_fitting_3/data/ellipe0.003.off -text svneol=unset#application/octet-stream
Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h -text
Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Bbox_2.h -text
Kernel_23/doc/Kernel_23/CGAL/Bbox_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Cartesian.h -text
Kernel_23/doc/Kernel_23/CGAL/Cartesian_converter.h -text
Kernel_23/doc/Kernel_23/CGAL/Circle_2.h -text
Kernel_23/doc/Kernel_23/CGAL/Circle_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Dimension.h -text
Kernel_23/doc/Kernel_23/CGAL/Direction_2.h -text
Kernel_23/doc/Kernel_23/CGAL/Direction_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Exact_predicates_exact_constructions_kernel.h -text
Kernel_23/doc/Kernel_23/CGAL/Exact_predicates_exact_constructions_kernel_with_sqrt.h -text
Kernel_23/doc/Kernel_23/CGAL/Exact_predicates_inexact_constructions_kernel.h -text
Kernel_23/doc/Kernel_23/CGAL/Filtered_kernel.h -text
Kernel_23/doc/Kernel_23/CGAL/Filtered_predicate.h -text
Kernel_23/doc/Kernel_23/CGAL/Homogeneous.h -text
Kernel_23/doc/Kernel_23/CGAL/Homogeneous_converter.h -text
Kernel_23/doc/Kernel_23/CGAL/Iso_cuboid_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Iso_rectangle_2.h -text
Kernel_23/doc/Kernel_23/CGAL/Kernel_traits.h -text
Kernel_23/doc/Kernel_23/CGAL/Line_2.h -text
Kernel_23/doc/Kernel_23/CGAL/Line_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Origin.h -text
Kernel_23/doc/Kernel_23/CGAL/Plane_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Point_2.h -text
Kernel_23/doc/Kernel_23/CGAL/Point_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Projection_traits_xy_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Ray_2.h -text
Kernel_23/doc/Kernel_23/CGAL/Ray_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Segment_2.h -text
Kernel_23/doc/Kernel_23/CGAL/Segment_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Simple_cartesian.h -text
Kernel_23/doc/Kernel_23/CGAL/Simple_homogeneous.h -text
Kernel_23/doc/Kernel_23/CGAL/Sphere_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Tetrahedron_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Triangle_2.h -text
Kernel_23/doc/Kernel_23/CGAL/Triangle_3.h -text
Kernel_23/doc/Kernel_23/CGAL/Vector_2.h -text
Kernel_23/doc/Kernel_23/CGAL/Vector_3.h -text
Kernel_23/doc/Kernel_23/CGAL/aff_transformation_tags.h -text
Kernel_23/doc/Kernel_23/CGAL/cartesian_homogeneous_conversion.h -text
Kernel_23/doc/Kernel_23/CGAL/enum.h -text
Kernel_23/doc/Kernel_23/CGAL/global_functions.h -text
Kernel_23/doc/Kernel_23/CGAL/intersections.h -text
Kernel_23/doc/Kernel_23/CGAL/rational_rotation.h -text
Kernel_23/doc/Kernel_23/CGAL/squared_distance_2.h -text
Kernel_23/doc/Kernel_23/CGAL/squared_distance_3.h -text
Kernel_23/doc/Kernel_23/Concepts/Kernel.h -text
Kernel_23/doc/Kernel_23/Kernel_23.txt -text
Kernel_23/doc/Kernel_23/PackageDescription.txt -text
Kernel_23/doc/Kernel_23/fig/IsoCuboid.gif -text svneol=unset#image/gif
Kernel_23/doc/Kernel_23/fig/IsoCuboid.pdf -text svneol=unset#application/pdf
Kernel_23/doc/Kernel_23/fig/arrlinthree.gif -text svneol=unset#image/gif
Kernel_23/doc/Kernel_23/fig/arrlintwo.gif -text svneol=unset#image/gif
Kernel_23/doc/Kernel_23/fig/arrthree.gif -text svneol=unset#image/gif
Kernel_23/doc/Kernel_23/fig/arrthree2.gif -text svneol=unset#image/gif
Kernel_23/doc/Kernel_23/fig/arrtwo.gif -text svneol=unset#image/gif
Kernel_23/doc/Kernel_23/fig/arrtwo2.gif -text svneol=unset#image/gif
Kernel_23/doc/Kernel_23/fig/compare1.gif -text svneol=unset#image/gif
Kernel_23/doc/Kernel_23/fig/compare1.pdf -text svneol=unset#application/pdf
Kernel_23/doc/Kernel_23/fig/compare2.gif -text svneol=unset#image/gif
Kernel_23/doc/Kernel_23/fig/compare2.pdf -text svneol=unset#application/pdf
Kernel_23/doc/Kernel_23/fig/compare_x_at_y.gif -text svneol=unset#image/gif
Kernel_23/doc/Kernel_23/fig/compare_x_at_y.pdf -text svneol=unset#application/pdf
Kernel_23/doc/Kernel_23/fig/pointSegmentTriangle.png -text svneol=unset#image/png
Kernel_23/doc/Kernel_23/fig/transvecthree.gif -text svneol=unset#image/gif
Kernel_23/doc/Kernel_23/fig/transvectwo.gif -text svneol=unset#image/gif
Kernel_23/doc_tex/Kernel_23/fig/pointSegmentTriangle.png -text
Kernel_23/doc_tex/Kernel_23_ref/Kernel_ConstructRadicalLine_2.tex -text
Kernel_23/doc_tex/Kernel_23_ref/compare_lexicographically.tex -text

View File

@ -0,0 +1,290 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
The class `Aff_transformation_2` represents two-dimensional affine transformations.
The general form of an affine transformation is based on a homogeneous
representation of points. Thereby all transformations can be realized by
matrix multiplications.
Multiplying the transformation matrix by a scalar does not change the
represented transformation. Therefore, any transformation represented
by a matrix with rational entries can be represented by a
transformation matrix with integer entries as well. (Multiply the
matrix with the common denominator of the rational entries.) Hence, it
is sufficient to use the number type `Kernel::RT` to represent
the entries of the transformation matrix.
\cgal offers several specialized affine transformations. Different
constructors are provided to create them. They are parameterized with
a symbolic name to denote the transformation type, followed by
additional parameters. The symbolic name tags solve ambiguities in the
function overloading and they make the code more readable, i.e., what
type of transformation is created.
Since two-dimensional points have three homogeneous coordinates, we
have a \f$ 3\times 3\f$ matrix \f$ {(m_{ij})}_{i,\,j=0\ldots 2}\f$.
If the homogeneous representations are normalized (the homogenizing
coordinate is 1), then the upper left \f$ 2\times 2\f$ matrix realizes
linear transformations. In the matrix form of a translation, the
translation vector \f$ (v_0,\,v_1,\,1)\f$ appears in the last column of the
matrix. The entries \f$ m_{20}\f$ and \f$ m_{21}\f$ are always zero and
therefore do not appear in the constructors.
\sa `Identity_transformation`
\sa `Rotation`
\sa `Scaling`
\sa `Translation`
\sa `rational_rotation_approximation`
Example
--------------
\code
typedef Cartesian<double> K;
typedef Aff_transformation_2<K> Transformation;
typedef Point_2<K> Point;
typedef Vector_2<K> Vector;
typedef Direction_2<K> Direction;
Transformation rotate(ROTATION, sin(pi), cos(pi));
Transformation rational_rotate(ROTATION,Direction(1,1), 1, 100);
Transformation translate(TRANSLATION, Vector(-2, 0));
Transformation scale(SCALING, 3);
Point q(0, 1);
q = rational_rotate(q);
Point p(1, 1);
p = rotate(p);
p = translate(p);
p = scale(p);
\endcode
The same would have been achieved with
\code
Transformation transform = scale * (translate * rotate);
p = transform(Point(1.0, 1.0));
\endcode
\sa `CGAL::Aff_transformation_3<Kernel>`
\sa `CGAL::Identity_transformation`
\sa `CGAL::Reflection`
\sa `CGAL::Rotation`
\sa `CGAL::Scaling`
\sa `CGAL::Translation`
*/
template< typename Kernel >
class Aff_transformation_2 {
public:
/// \name Creation
/// @{
/*!
introduces an identity transformation.
*/
Aff_transformation_2(const Identity_transformation& );
/*!
introduces a translation by a vector \f$ v\f$.
*/
Aff_transformation_2(const Translation,
const Vector_2<Kernel> &v);
/*!
approximates the rotation over the angle indicated by direction
\f$ d\f$, such that the differences between the sines and cosines
of the rotation given by d and the approximating rotation
are at most \f$ num/den\f$ each.
\pre \f$ num/den>0\f$ and \f$ d != 0\f$.
*/
Aff_transformation_2(const Rotation,
const Direction_2<Kernel> &d,
const Kernel::RT &num,
const Kernel::RT &den = RT(1));
/*!
introduces a rotation by the angle `rho`.
\pre \f$ sine\_rho^2 + cosine\_rho^2 == hw^2\f$.
*/
Aff_transformation_2(const Rotation,
const Kernel::RT &sine_rho,
const Kernel::RT &cosine_rho,
const Kernel::RT &hw = RT(1));
/*!
introduces a scaling by a scale factor \f$ s/hw\f$.
*/
Aff_transformation_2(const Scaling,
const Kernel::RT &s,
const Kernel::RT &hw = RT(1));
/*!
introduces a general affine transformation in the
\f$3 \times 3\f$ matrix form
\f$
\small \mbox{\( \left(\begin{array}{ccc}
m_{00} & m_{01} & m_{02}\\
m_{10} & m_{11} & m_{12}\\
0 & 0 & hw
\end{array}\right) \)}
\f$.
The sub-matrix
\f$1\over hw\f$ \f$\small \mbox{\( \left(\begin{array}{cc}
m_{00} & m_{01}\\
m_{10} & m_{11}
\end{array}\right) \) }
\f$ contains the scaling and rotation
information, the vector
\f$ \small
\left(
\begin{array}{c}
m_{02}\\
m_{12}
\end{array}
\right)
\f$
contains the translational part of the transformation.
*/
Aff_transformation_2(
const Kernel::RT &m00, const Kernel::RT &m01, const Kernel::RT &m02,
const Kernel::RT &m10, const Kernel::RT &m11, const Kernel::RT &m12,
const Kernel::RT &hw = RT(1));
/*!
introduces a general linear transformation
\f$\small \mbox{\(\left(\begin{array}{ccc}
m_{00} & m_{01} & 0\\
m_{10} & m_{11} & 0\\
0 & 0 & hw
\end{array}\right)\)}\f$
i.e.\ there is no translational part.
*/
Aff_transformation_2(
const Kernel::RT &m00, const Kernel::RT &m01,
const Kernel::RT &m10, const Kernel::RT &m11,
const Kernel::RT &hw = RT(1));
/// @}
/*!
\name Operations
The main thing to do with transformations is to apply them on
geometric objects. Each class `Class_2<Kernel>` representing a
geometric object has a member function:
\code
Class_2<Kernel> transform(Aff_transformation_2<Kernel> t)`.
\endcode
The transformation classes provide a member function `transform()` for
points, vectors, directions, and lines. The same functionality is also
available through `operator()` overloads.
/// @{
/*!
*/
Point_2<Kernel> transform(const Point_2<Kernel> &p) const;
/*!
*/
Vector_2<Kernel> transform(const Vector_2<Kernel> &p) const;
/*!
*/
Direction_2<Kernel> transform(const Direction_2<Kernel> &p) const;
/*!
*/
Line_2<Kernel> transform(const Line_2<Kernel> &p) const;
/*!
*/
Point_2<Kernel> operator()(const Point_2<Kernel> &p) const;
/*!
*/
Vector_2<Kernel> operator()(const Vector_2<Kernel> &p) const;
/*!
*/
Direction_2<Kernel> operator()(const Direction_2<Kernel> &p) const;
/*!
*/
Line_2<Kernel> operator()(const Line_2<Kernel> &p) const;
/// @}
/// \name Miscellaneous
/// @{
/*!
composes two affine transformations.
*/
Aff_transformation_2<Kernel> operator*(const Aff_transformation_2<Kernel> &s) const;
/*!
gives the inverse transformation.
*/
Aff_transformation_2<Kernel> inverse() const;
/*!
returns `true`, if the transformation is not reflecting,
i.e. the determinant of the involved linear transformation is
non-negative.
*/
bool is_even() const;
/*!
returns `true`, if the transformation is reflecting.
*/
bool is_odd() const;
/// @}
/// \name Matrix Entry Access
/// @{
/*!
*/
Kernel::FT cartesian(int i, int j) const;
/*!
returns entry \f$ m_{ij}\f$ in a matrix representation in which \f$ m_{22}\f$ is 1.
*/
Kernel::FT m(int i, int j) const;
/*!
*/
Kernel::RT homogeneous(int i, int j) const;
/*!
returns entry \f$ m_{ij}\f$ in some fixed matrix representation.
*/
Kernel::RT hm(int i, int j) const;
/// @}
}; /* end Aff_transformation_2 */
} /* end namespace CGAL */

View File

@ -0,0 +1,222 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
The class `Aff_transformation_3` represents three-dimensional affine transformations.
The general form of an affine transformation is based on a homogeneous
representation of points. Thereby all transformations can be realized by
matrix multiplication.
Multiplying the transformation matrix by a scalar does not change the
represented transformation. Therefore, any transformation represented
by a matrix with rational entries can be represented by a
transformation matrix with integer entries as well. (Multiply the
matrix with the common denominator of the rational entries.) Hence, it
is sufficient to use the number type `Kernel::RT` to represent
the entries of the transformation matrix.
\cgal offers several specialized affine transformations. Different
constructors are provided to create them. They are parameterized with
a symbolic name to denote the transformation type, followed by
additional parameters. The symbolic name tags solve ambiguities in the
function overloading and they make the code more readable, i.e., what
type of transformation is created.
In three-dimensional space we have a \f$ 4\times 4\f$ matrix
\f$ {(m_{ij})}_{i,\,j=0\ldots 3}\f$. Entries \f$ m_{30}\f$, \f$ m_{31}\f$, and
\f$ m_{32}\f$ are always zero and therefore do not appear in the
constructors.
\sa `CGAL::Aff_transformation_2<Kernel>`
\sa `CGAL::Identity_transformation`
\sa `CGAL::Reflection`
\sa `CGAL::Rotation`
\sa `CGAL::Scaling`
\sa `CGAL::Translation`
*/
template< typename Kernel >
class Aff_transformation_3 {
public:
/// \name Creation
/// @{
/*!
introduces an identity transformation.
*/
Aff_transformation_3(const Identity_transformation& );
/*!
introduces a translation by a vector \f$ v\f$.
*/
Aff_transformation_3(const Translation,
const Vector_3<Kernel> &v);
/*!
introduces a scaling by a scale factor \f$ s/hw\f$.
*/
Aff_transformation_3(const Scaling,
const Kernel::RT &s,
const Kernel::RT &hw = RT(1));
/*!
introduces a general affine transformation of the matrix
form
\f$
\small \mbox{\(\left(\begin{array}{cccc}
m_{00} & m_{01} & m_{02} & m_{03}\\
m_{10} & m_{11} & m_{12} & m_{13}\\
m_{20} & m_{21} & m_{22} & m_{23}\\
0 & 0 & 0 & hw
\end{array}\right)\)}
\f$.
The part \f$1\over hw\f$ \f$ \small \mbox{\(\left(\begin{array}{ccc}
m_{00} & m_{01} & m_{02}\\
m_{10} & m_{11} & m_{12}\\
m_{20} & m_{21} & m_{22}\\
\end{array}\right)\)} \f$ defines the scaling
and rotational part of the transformation,
while the vector \f$1\over hw\f$ \f$\small \mbox{\(\left(\begin{array}{c}
m_{03}\\
m_{13}\\
m_{23}
\end{array}\right)\)}\f$ contains the translational part.
*/
Aff_transformation_3(
const Kernel::RT &m00, const Kernel::RT &m01, const Kernel::RT &m02, const Kernel::RT &m03,
const Kernel::RT &m10, const Kernel::RT &m11, const Kernel::RT &m12, const Kernel::RT &m13,
const Kernel::RT &m20, const Kernel::RT &m21, const Kernel::RT &m22, const Kernel::RT &m23,
const Kernel::RT &hw = RT(1));
/*!
introduces a general linear transformation of the
matrix form \f$
\small \mbox{\(\left(\begin{array}{cccc}
m_{00} & m_{01} & m_{02} & 0\\
m_{10} & m_{11} & m_{12} & 0\\
m_{20} & m_{21} & m_{22} & 0\\
0 & 0 & 0 & hw
\end{array}\right)\)}
\f$, i.e.\ an affine transformation without translational part.
*/
Aff_transformation_3(
const Kernel::RT &m00, const Kernel::RT &m01, const Kernel::RT& m02,
const Kernel::RT &m10, const Kernel::RT &m11, const Kernel::RT& m12,
const Kernel::RT &m20, const Kernel::RT &m21, const Kernel::RT& m22,
const Kernel::RT &hw = RT(1));
/// @}
/*!
\name Operations
The main thing to do with transformations is to apply them on
geometric objects. Each class `Class_2<Kernel>` representing a
geometric object has a member function:
\code
Class_3<Kernel> transform(Aff_transformation_3<Kernel> t)
\endcode
The transformation classes provide a member function `transform()` for
points, vectors, directions, and planes. The same functionality is also
available through `operator()` overloads.
*/
/// @{
/*!
*/
Point_3<Kernel> transform(const Point_3<Kernel> &p) const;
/*!
*/
Vector_3<Kernel> transform(const Vector_3<Kernel> &p) const;
/*!
*/
Direction_3<Kernel> transform(const Direction_3<Kernel> &p) const;
/*!
*/
Plane_3<Kernel> transform(const Plane_3<Kernel> &p) const;
/*!
*/
Point_3<Kernel> operator()(const Point_3<Kernel> &p) const;
/*!
*/
Vector_3<Kernel> operator()(const Vector_3<Kernel> &p) const;
/*!
*/
Direction_3<Kernel> operator()(const Direction_3<Kernel> &p) const;
/*!
*/
Plane_3<Kernel> operator()(const Plane_3<Kernel> &p) const;
/*!
composes two affine transformations.
*/
Aff_transformation_3<Kernel>
operator*(const Aff_transformation_3<Kernel> &s) const;
/*!
gives the inverse transformation.
*/
Aff_transformation_3<Kernel> inverse() const;
/*!
returns `true`, if the transformation is not reflecting,
i.e. the determinant of the involved linear transformation is
non-negative.
*/
bool is_even() const;
/*!
returns `true`, if the transformation is reflecting.
*/
bool is_odd() const;
/// @}
/// \name Matrix Entry Access
/// @{
/*!
*/
Kernel::FT cartesian(int i, int j) const;
/*!
returns entry \f$ m_{ij}\f$ in a matrix representation in which \f$ m_{33}\f$ is 1.
*/
Kernel::FT m(int i, int j) const;
/*!
*/
Kernel::RT homogeneous(int i, int j) const;
/*!
returns entry \f$ m_{ij}\f$ in some fixed matrix representation.
*/
Kernel::RT hm(int i, int j) const;
/// @}
}; /* end Aff_transformation_3 */
} /* end namespace CGAL */

View File

@ -0,0 +1,99 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object `b` of the class `Bbox_2` is a bounding
box in the two-dimensional Euclidean plane \f$ \E^2\f$. This class is not templated.
\sa `CGAL::Bbox_3`
\sa `CGAL::do_overlap`
*/
class Bbox_2 {
public:
/// \name Creation
/// @{
/*!
introduces a bounding box `b` with lower left corner at
`(xmin, ymin)` and with upper right corner at
`(xmax, ymax)`.
*/
Bbox_2(double x_min, double y_min,
double x_max, double y_max);
/// @}
/// \name Operations
/// @{
/*!
Test for equality.
*/
bool operator==(const Bbox_2 &c) const;
/*!
Test for inequality.
*/
bool operator!=(const Bbox_2 &q) const;
/*!
Returns 2.
*/
int dimension() const;
/*!
*/
double xmin() const;
/*!
*/
double ymin() const;
/*!
*/
double xmax() const;
/*!
*/
double ymax() const;
/*!
Returns `xmin()` if `i==0` or `ymin()` if `i==1`.
\pre i==0 or i==1
*/
double min(int i) const;
/*!
Returns `xmax()` if `i==0` or `ymax()` if `i==1`.
\pre i==0 or i==1
*/
double max(int i) const;
/*!
returns a bounding box of `b` and `c`.
*/
Bbox_2 operator+(const Bbox_2 &c) const;
/// @}
}; /* end Bbox_2 */
/*!
returns `true` iff `bb1` and `bb2` overlap, i.e., iff their
intersection is non-empty.
\relates Bbox_2
*/
bool do_overlap(const Bbox_2 &bb1, const Bbox_2 &bb2);
} /* end namespace CGAL */

View File

@ -0,0 +1,111 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object `b` of the class `Bbox_3` is a bounding
box in the three-dimensional Euclidean space \f$ \E^3\f$.
\sa `CGAL::Bbox_2`
\sa `CGAL::do_overlap`
*/
class Bbox_3 {
public:
/// \name Creation
/// @{
/*!
introduces a bounding box `b` with lexicographically
smallest corner point at `(xmin, ymin, zmin)`
lexicographically largest corner point at
`(xmax, ymax, zmax)`.
*/
Bbox_3(double x_min, double y_min, double z_min,
double x_max, double y_max, double z_max);
/// @}
/// \name Operations
/// @{
/*!
Test for equality.
*/
bool operator==(const Bbox_3 &c) const;
/*!
Test for inequality.
*/
bool operator!=(const Bbox_3 &q) const;
/*!
Returns 3.
*/
int dimension() const;
/*!
*/
double xmin() const;
/*!
*/
double ymin() const;
/*!
*/
double zmin() const;
/*!
*/
double xmax() const;
/*!
*/
double ymax() const;
/*!
*/
double zmax() const;
/*!
Returns `xmin()` if `i==0` or `ymin()` if `i==1`
or `zmin()` if `i==2`.
\pre i<=0 and i<=2
*/
double min(int i) const;
/*!
Returns `xmax()` if `i==0` or `ymax()` if `i==1`
or `zmax()` if `i==2`.
\pre i==0 and i<=2
*/
double max(int i) const;
/*!
returns a bounding box of `b` and `c`.
*/
Bbox_3 operator+(const Bbox_3 &c) const;
/// @}
}; /* end Bbox_3 */
/*!
returns `true` iff `bb1` and `bb2` overlap, i.e., iff their
intersection is non-empty.
\relates Bbox_3
*/
bool do_overlap(const Bbox_3 &bb1, const Bbox_3 &bb2);
} /* end namespace CGAL */

View File

@ -0,0 +1,49 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
A model for `Kernel` that uses Cartesian coordinates to represent the
geometric objects. In order for `Cartesian` to model Euclidean geometry
in \f$ E^2\f$ and/or \f$ E^3\f$, for some mathematical field \f$ E\f$ (<I>e.g.</I>,
the rationals \f$\mathbb{Q}\f$ or the reals \f$\mathbb{R}\f$), the template parameter `FieldNumberType`
must model the mathematical field \f$ E\f$. That is, the field operations on this
number type must compute the mathematically correct results. If the number
type provided as a model for `FieldNumberType` is only an approximation of a
field (such as the built-in type `double`), then the geometry provided by
the kernel is only an approximation of Euclidean geometry.
\models ::Kernel
Implementation
--------------
All geometric objects in `Cartesian` are reference counted.
\sa `CGAL::Simple_cartesian<FieldNumberType>`
\sa `CGAL::Homogeneous<RingNumberType>`
\sa `CGAL::Simple_homogeneous<RingNumberType>`
*/
template< typename FieldNumberType >
class Cartesian {
public:
/// \name Types
/// @{
/*!
*/
typedef FieldNumberType FT;
/*!
*/
typedef FieldNumberType RT;
/// @}
}; /* end Cartesian */
} /* end namespace CGAL */

View File

@ -0,0 +1,60 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
`Cartesian_converter`converts objects from the kernel traits `K1` to
the kernel traits `K2` using `Converter` to do the conversion.
Those traits must be of the form
`Cartesian<FT1>` and `Cartesian<FT2>` (or the equivalent with
`Simple_cartesian`). It then provides the following operators to convert
objects from `K1` to `K2`.
The third template parameter `NTConverter` is a function object that must
provide `K2::FT operator()(K1::FT n)` that converts `n` to an
`K2::FT` which has the same value.
The default value of this parameter is `CGAL::NT_converter<K1::FT, K2::FT>`.
Example
--------------
In the following example, we compute exactly
the intersection point between a line and a triangle,
and we then create a double approximation of this point.
\cgalexample{cartesian_converter.cpp}
\sa `CGAL::Cartesian<FieldNumberType>`
\sa `CGAL::Simple_cartesian<FieldNumberType>`
*/
template< typename K1, typename K2, typename NTConverter >
class Cartesian_converter {
public:
/// \name Creation
/// @{
/*!
Default constructor.
*/
Cartesian_converter<>();
/// @}
/// \name Operations
/// Similar operators are defined for the other kernel traits types `Point_3`, `Vector_2`...
/// @{
/*!
returns a `K2::Point_2` which coordinates are those of `p`,
converted by `NTConverter`.
*/
K2::Point_2 operator()(const K1::Point_2&p);
/// @}
}; /* end Cartesian_converter */
} /* end namespace CGAL */

View File

@ -0,0 +1,196 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object of type `Circle_2` is a circle in the
two-dimensional Euclidean plane \f$ \E^2\f$. The circle is oriented, i.e.
its boundary has clockwise or counterclockwise orientation. The
boundary splits \f$ \E^2\f$ into a positive and a negative side, where the
positive side is to the left of the boundary. The boundary also
splits \f$ \E^2\f$ into a bounded and an unbounded side. Note that the
circle can be degenerated, i.e. the squared radius may be zero.
\sa `Kernel::Circle_2`
*/
template< typename Kernel >
class Circle_2 {
public:
/// \name Creation
/// @{
/*!
introduces a variable `c` of type `Circle_2`.
It is initialized to the circle with center `center`,
squared radius `squared_radius` and orientation
`ori`.
\pre `ori` \f$ \neq\f$ `COLLINEAR`, and further, `squared_radius` \f$ \geq\f$ 0.
*/
Circle_2( Point_2<Kernel> const& center,
Kernel::FT const& squared_radius,
Orientation const& ori = COUNTERCLOCKWISE);
/*!
introduces a variable `c` of type `Circle_2`.
It is initialized to the unique circle which passes through
the points `p`, `q` and `r`. The orientation of
the circle is the orientation of the point triple `p`,
`q`, `r`.
\pre `p`, `q`, and `r` are not collinear.
*/
Circle_2( Point_2<Kernel> const& p,
Point_2<Kernel> const& q,
Point_2<Kernel> const& r);
/*!
introduces a variable `c` of type `Circle_2`.
It is initialized to the circle with diameter \f$ \overline{pq}\f$
and orientation `ori`.
\pre `ori` \f$ \neq\f$ `COLLINEAR`.
*/
Circle_2( Point_2<Kernel> const& p,
Point_2<Kernel> const& q,
Orientation const& ori
= COUNTERCLOCKWISE);
/*!
introduces a variable `c` of type `Circle_2`.
It is initialized to the circle with center `center`, squared
radius zero and orientation `ori`.
\pre `ori` \f$ \neq\f$ `COLLINEAR`.
\post `c`.`is_degenerate()` = `true`.
*/
Circle_2( Point_2<Kernel> const& center,
Orientation const& ori
= COUNTERCLOCKWISE);
/// @}
/// \name Access Functions
/// @{
/*!
returns the center of `c`.
*/
Point_2<Kernel> const& center( ) const;
/*!
returns the squared radius of `c`.
*/
Kernel::FT const& squared_radius( ) const;
/*!
returns the orientation of `c`.
*/
Orientation const& orientation( ) const;
/*!
returns `true`, iff `c` and `circle2` are equal,
i.e. if they have the same center, same squared radius and
same orientation.
*/
bool operator == ( Circle_2<Kernel> const& circle2) const;
/*!
returns `true`, iff `c` and `circle2` are not equal.
*/
bool operator != ( Circle_2<Kernel> const& circle2) const;
/// @}
/// \name Predicates
/// @{
/*!
returns `true`, iff `c` is degenerate, i.e. if `c` has squared radius zero.
*/
bool is_degenerate( ) const;
/*!
returns either the constant `ON_ORIENTED_BOUNDARY`,
`ON_POSITIVE_SIDE`, or `ON_NEGATIVE_SIDE`,
iff `p` lies on the boundary, properly on the
positive side, or properly on the negative side
of `c`, resp.
*/
Oriented_side
oriented_side( Point_2<Kernel> const& p) const;
/*!
returns `ON_BOUNDED_SIDE`,
`ON_BOUNDARY`, or `ON_UNBOUNDED_SIDE`
iff `p` lies properly inside, on the boundary, or properly
outside of `c`, resp.
*/
Bounded_side
bounded_side( Point_2<Kernel> const& p) const;
/*!
*/
bool has_on_positive_side(const Point_2<Kernel> &p) const;
/*!
*/
bool has_on_negative_side(const Point_2<Kernel> &p) const;
/*!
*/
bool has_on_boundary(const Point_2<Kernel> &p) const;
/*!
*/
bool has_on_bounded_side(const Point_2<Kernel> &p) const;
/*!
*/
bool has_on_unbounded_side(const Point_2<Kernel> &p) const;
/// @}
/// \name Miscellaneous
/// @{
/*!
returns the circle with the same center and squared radius as
`c` but with opposite orientation.
*/
Circle_2<Kernel> opposite() const;
/*!
returns the circle obtained by applying \f$ at\f$ on `c`.
\pre `at` is an orthogonal transformation.
*/
Circle_2<Kernel> orthogonal_transform(
Aff_transformation_2<Kernel> const& at) const;
/*!
returns a bounding box containing `c`.
*/
Bbox_2 bbox() const;
/// @}
}; /* end Circle_2 */
} /* end namespace CGAL */

View File

@ -0,0 +1,169 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object of type `Circle_3` is a circle in the
three-dimensional Euclidean space \f$ \E^3\f$. Note that the
circle can be degenerate, i.e. the squared radius may be zero.
\sa `Kernel::Circle_3`
*/
template< typename Kernel >
class Circle_3 {
public:
/// \name Creation
/// @{
/*!
introduces a variable `c` of type `Circle_3`.
It is initialized to the circle of center `center` and
squared radius `sq_r` in plane `plane`.
\pre `center` lies in `plane` and `sq_r` \f$ \geq\f$ 0.
*/
Circle_3(Point_3<Kernel> const& center,
Kernel::FT const& sq_r,
Plane_3<Kernel> const& plane);
/*!
introduces a variable `c` of type `Circle_3`.
It is initialized to the circle of center `center` and
squared radius `sq_r` in a plane normal to
the vector `n`.
\pre `sq_r` \f$ \geq\f$ 0.
*/
Circle_3(Point_3<Kernel> const& center,
Kernel::FT const& sq_r,
Vector_3<Kernel> const& n);
/*!
introduces a variable `c` of type `Circle_3`.
It is initialized to the circle passing through the three points.
\pre The three points are not collinear.
*/
Circle_3(Point_3<Kernel> const& p,
Point_3<Kernel> const& q, Point_3<Kernel> const& r);
/*!
introduces a variable `c` of type `Circle_3`.
It is initialized to the circle along which the two spheres intersect.
\pre The two spheres intersect along a circle.
*/
Circle_3(Sphere_3<Kernel> const& sphere1,
Sphere_3<Kernel> const& sphere2);
/*!
introduces a variable `c` of type `Circle_3`.
It is initialized to the circle along which the sphere and the
plane intersect.
\pre The sphere and the plane intersect along a circle.
*/
Circle_3(Sphere_3<Kernel> const& sphere,
Plane_3<Kernel> const& plane);
/*!
introduces a variable `c` of type `Circle_3`.
It is initialized to the circle along which the sphere and the
plane intersect.
\pre The sphere and the plane intersect along a circle.
*/
Circle_3(Plane_3<Kernel> const& plane,
Sphere_3<Kernel> const& sphere);
/// @}
/// \name Access Functions
/// @{
/*!
returns the center of `c`.
*/
Point_3<Kernel> const& center( ) const;
/*!
returns the squared radius of `c`.
*/
Kernel::FT const& squared_radius( ) const;
/*!
returns the supporting plane of `c`.
*/
Plane_3<Kernel> const& supporting_plane( ) const;
/*!
returns the diametral sphere of `c`.
*/
Sphere_3<Kernel> const& diametral_sphere( ) const;
/*!
returns the area of `c`, divided by \f$ \pi\f$.
*/
Kernel::FT const& area_divided_by_pi( ) const;
/*!
returns an approximation of the area of `c`.
*/
double const& approximate_area( ) const;
/*!
returns the squared length of `c`, divided by \f$ \pi^2\f$.
*/
Kernel::FT const& squared_length_divided_by_pi_square( ) const;
/*!
returns an approximation of the squared length (i.e. perimeter) of `c`.
*/
double const& approximate_squared_length( ) const;
/// @}
/// \name Predicates
/// @{
/*!
*/
bool has_on(Point_3<Kernel> const& p) const;
/// @}
/// \name Operations
/// @{
/*!
returns a bounding box containing `c`.
*/
Bbox_3 bbox() const;
/// @}
}; /* end Circle_3 */
/*!
returns `true`, iff `c1` and `c2` are equal,
i.e. if they have the same center, the same squared radius
and the same supporting plane.
\relates Circle_3
*/
bool operator == (Circle_3<Kernel> const& c1,
Circle_3<Kernel> const& c2);
/*!
\relates Circle_3
*/
bool operator != (Circle_3<Kernel> const& c1,
Circle_3<Kernel> const& c2);
} /* end namespace CGAL */

View File

@ -0,0 +1,200 @@
namespace CGAL {
/// \defgroup kernel_dimension Dimension Handling
/// \ingroup PkgKernel23
/// Tools to handle the dimension of a Kernel.
/// @{
/*!
The class `Ambient_dimension` allows to retrieve the dimension of the ambient space of
a type `T` in a kernel `K`.
Parameters
--------------
The parameter `K` has the default value `Kernel_traits<T>::Kernel>`.
Example
--------------
The following retrieves the dimension of a point type.
<PRE>
typedef K::Point_2 Point;
int dimension = Ambient_dimension<Point, K>::value;
assert(dimension == 2);
</PRE>
\sa `CGAL::Dimension_tag<int dim>`
\sa `CGAL::Dynamic_dimension_tag`
\sa `CGAL::Feature_dimension<T, K>`
*/
template< typename T, typename K >
class Ambient_dimension {
public:
/// \name Constants
/// @{
/*!
The dimension value as a compile-time
integral constant. It is implemented as `K::Dimension<T>::type::value`.
It exists only when the dimension is a compile-time constant.
*/
static const int value;
/// @}
/// \name Types
/// @{
/*!
Either `Dimension_tag<dim>` if the dimension is a
compile-time constant of value `dim`, or `Dynamic_dimension_tag`
otherwise. It is implemented as `K::Ambient_dimension<T>::type`.
*/
typedef Hidden_type type;
/// @}
}; /* end Ambient_dimension */
/*!
An object of the class `Dimension_tag` is an empty object which can be used
for dispatching functions based on the dimension of an object, as provided
by the `dim` parameter. It is useful in cases where it is not more
practical to pass the dimension as a template parameter directly.
Example
--------------
The following code declares two functions constructing two points at the origin,
either in 2D or in 3D.
<PRE>
Point_2<K> get_origin(Dimension_tag<2>) { return Point_2<K>(ORIGIN); }
Point_3<K> get_origin(Dimension_tag<3>) { return Point_3<K>(ORIGIN); }
std::cout << get_origin(Dimension_tag<2>())) << std::endl;
[cccend]</PRE>
\sa `CGAL::Ambient_dimension<T, K>`
\sa `CGAL::Feature_dimension<T, K>`
\sa `CGAL::Dynamic_dimension_tag`
*/
template< typename int dim >
class Dimension_tag {
public:
/// \name Constants
/// @{
/*!
The value of the `dim` parameter.
*/
static const int value;
/// @}
}; /* end Dimension_tag */
/*!
An object of the class `Dynamic_dimension_tag` is an empty object which can be used
for dispatching functions based on the dimension of an object.
`Dynamic_dimension_tag` indicates that the dimension is not known at compile-time.
`Dimension_tag` is the tag class dealing with compile-time dimensions.
Example
--------------
The following code declares two functions constructing two points at the origin,
either in 2D or in 3D.
<PRE>
Point_2<K> get_origin(Dimension_tag<2>) { return Point_2<K>(ORIGIN); }
Point_3<K> get_origin(Dimension_tag<3>) { return Point_3<K>(ORIGIN); }
Point_d<K> get_origin(Dynamic_dimension_tag) { return Point_d<K>(ORIGIN); }
std::cout << get_origin(Dynamic_dimension_tag())) << std::endl;
[cccend]</PRE>
\sa `CGAL::Dimension_tag<int dim>`
\sa `CGAL::Ambient_dimension<T, K>`
\sa `CGAL::Feature_dimension<T, K>`
*/
class Dynamic_dimension_tag {
public:
/// @}
}; /* end Dynamic_dimension_tag */
/*!
The class `Feature_dimension` allows to retrieve the geometric dimension of a type `T`
in a kernel `K`.
Parameters
--------------
The parameter `K` has the default value `Kernel_traits<T>::Kernel`.
Example
--------------
The following retrieves the dimension of a point type.
<PRE>[cccbegin]
typedef K::Point_2 Point;
int dimension = Feature_dimension<Point, K>::value;
assert(dimension == 0);
</PRE>
\sa `CGAL::Dimension_tag<int dim>`
\sa `CGAL::Dynamic_dimension_tag`
\sa `CGAL::Ambient_dimension<T, K>`
*/
template< typename T, typename K >
class Feature_dimension {
public:
/// \name Constants
/// @{
/*!
The dimension value as a compile-time
integral constant. It is implemented as `K::Feature_dimension<T>::type::value`.
It exists only when the dimension is a compile-time constant.
*/
static const int value;
/// @}
/// \name Types
/// @{
/*!
Either `Dimension_tag<dim>` if the dimension is a
compile-time constant of value `dim`, or `Dynamic_dimension_tag`
otherwise. It is implemented as `K::Feature_dimension<T>::type`.
*/
typedef Hidden_type type;
/// @}
}; /* end Feature_dimension */
/// @}
} /* end namespace CGAL */

View File

@ -0,0 +1,141 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object of the class `Direction_2` is a vector in the two-dimensional
vector space \f$ \R^2\f$ where we forget about its length. They can be
viewed as unit vectors, although there is no normalization internally,
since this is error prone. Directions are used whenever the length of
a vector does not matter.
They also characterize a set of parallel oriented lines that have the same
orientations.
For example, you can ask for the direction
orthogonal to an oriented plane, or the direction of an oriented line.
Further, they can be used to indicate angles. The slope of a direction
is `dy()/dx()`.
\sa `Kernel::Direction_2`
*/
template< typename Kernel >
class Direction_2 {
public:
/// \name Creation
/// @{
/*!
introduces the direction `d` of vector \f$ v\f$.
*/
Direction_2(const Vector_2<Kernel> &v);
/*!
introduces the direction `d` of line \f$ l\f$.
*/
Direction_2(const Line_2<Kernel> &l);
/*!
introduces the direction `d` of ray \f$ r\f$.
*/
Direction_2(const Ray_2<Kernel> &r);
/*!
introduces the direction `d` of segment \f$ s\f$.
*/
Direction_2(const Segment_2<Kernel> &s);
/*!
introduces a direction `d` passing through the origin
and the point with Cartesian coordinates \f$ (x, y)\f$.
*/
Direction_2(const Kernel::RT &x, const Kernel::RT &y);
/// @}
/// \name Operations
/// There is a total order on directions. We compare the angles
/// between the positive \f$ x\f$-axis and the directions in
/// counterclockwise order.
/// @{
/*!
returns values, such that `d``== Direction_2<Kernel>(delta(0),delta(1))`.
\pre : \f$ 0 \leq i \leq1\f$.
*/
Kernel::RT delta(int i) const;
/*!
returns `delta(0)`.
*/
Kernel::RT dx() const;
/*!
returns `delta(1)`.
*/
Kernel::RT dy() const;
/*!
*/
bool operator==(const Direction_2<Kernel> &e) const;
/*!
*/
bool operator!=(const Direction_2<Kernel> &e) const;
/*!
*/
bool operator<(const Direction_2<Kernel> &e) const;
/*!
*/
bool operator>(const Direction_2<Kernel> &e) const;
/*!
*/
bool operator<=(const Direction_2<Kernel> &e) const;
/*!
*/
bool operator>=(const Direction_2<Kernel> &e) const;
/*!
returns true, iff `d` is not equal to `d1`, and
while rotating counterclockwise starting at `d1`,
`d` is reached strictly before `d2` is reached.
Note that true is returned if `d1` == `d2`, unless
also `d` == `d1`.
*/
bool counterclockwise_in_between(const Direction_2<Kernel> &d1,
const Direction_2<Kernel> &d2) const;
/*!
The direction opposite to `d`.
*/
Direction_2<Kernel> operator-() const;
/// @}
/// \name Miscellaneous
/// @{
/*!
returns a vector that has the same direction as `d`.
*/
Vector_2<Kernel> vector() const;
/*!
returns the direction obtained by applying \f$ t\f$ on `d`.
*/
Direction_2<Kernel> transform(const Aff_transformation_2<Kernel> &t) const;
/// @}
}; /* end Direction_2 */
} /* end namespace CGAL */

View File

@ -0,0 +1,107 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object of the class `Direction_3` is a vector in the three-dimensional
vector space \f$ \R^3\f$ where we forget about their length. They can be
viewed as unit vectors, although there is no normalization internally,
since this is error prone. Directions are used whenever the length of
a vector does not matter.
They also characterize a set of parallel lines that have the same orientation
or the direction normal to parallel planes that have the same orientation.
For example, you can ask for the direction
orthogonal to an oriented plane, or the direction of an oriented line.
\sa `Kernel::Direction_3`
*/
template< typename Kernel >
class Direction_3 {
public:
/// \name Creation
/// @{
/*!
introduces a direction `d` initialized with the
direction of vector \f$ v\f$.
*/
Direction_3(const Vector_3<Kernel> &v);
/*!
introduces the direction `d` of line \f$ l\f$.
*/
Direction_3(const Line_3<Kernel> &l);
/*!
introduces the direction `d` of ray \f$ r\f$.
*/
Direction_3(const Ray_3<Kernel> &r);
/*!
introduces the direction `d` of segment \f$ s\f$.
*/
Direction_3(const Segment_3<Kernel> &s);
/*!
introduces a direction `d` initialized with the direction
from the origin to the point with Cartesian coordinates \f$ (x, y, z)\f$.
*/
Direction_3(const Kernel::RT &x, const Kernel::RT &y, const Kernel::RT &z);
/// @}
/// \name Operations
/// @{
/*!
returns values, such that `d``== Direction_3<Kernel>(delta(0),delta(1),delta(2))`.
\pre : \f$ 0 \leq i \leq2\f$.
*/
Kernel::RT delta(int i) const;
/*!
returns `delta(0)`.
*/
Kernel::RT dx() const;
/*!
returns `delta(1)`.
*/
Kernel::RT dy() const;
/*!
returns `delta(2)`.
*/
Kernel::RT dz() const;
/*!
Test for equality.
*/
bool operator==(const Direction_3<Kernel> &e) const;
/*!
Test for inequality.
*/
bool operator!=(const Direction_3<Kernel> &e) const;
/*!
The direction opposite to `d`.
*/
Direction_3<Kernel> operator-() const;
/*!
returns a vector that has the same direction as `d`.
*/
Vector_3<Kernel> vector() const;
/*!
returns the direction obtained by applying \f$ t\f$ on `d`.
*/
Direction_3<Kernel> transform(const Aff_transformation_3<Kernel> &t) const;
/// @}
}; /* end Direction_3 */
} /* end namespace CGAL */

View File

@ -0,0 +1,31 @@
namespace CGAL {
/*!
\ingroup kernel_predef
A typedef to a kernel which has the following properties:
<UL>
<LI>It uses Cartesian representation.
<LI>It supports constructions of points from <TT>double</TT> Cartesian
coordinates.
<LI>It provides both exact geometric predicates and exact geometric
constructions.
</UL>
\models ::Kernel
\sa `CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt`
\sa `CGAL::Exact_predicates_inexact_constructions_kernel`
\sa `CGAL::Cartesian`
*/
class Exact_predicates_exact_constructions_kernel {
public:
/// @}
}; /* end Exact_predicates_exact_constructions_kernel */
} /* end namespace CGAL */

View File

@ -0,0 +1,34 @@
namespace CGAL {
/*!
\ingroup kernel_predef
A typedef to a kernel which has the following properties:
<UL>
<LI>It uses Cartesian representation.
<LI>It supports constructions of points from <TT>double</TT> Cartesian
coordinates.
<LI>It provides both exact geometric predicates and exact geometric
constructions.
<LI>Its `FT` nested type supports the square root operation `sqrt()`.
</UL>
Note that it requires CORE or LEDA installed.
\models ::Kernel
\sa `CGAL::Exact_predicates_exact_constructions_kernel`
\sa `CGAL::Exact_predicates_inexact_constructions_kernel`
\sa `CGAL::Cartesian`
*/
class Exact_predicates_exact_constructions_kernel_with_sqrt {
public:
/// @}
}; /* end Exact_predicates_exact_constructions_kernel_with_sqrt */
} /* end namespace CGAL */

View File

@ -0,0 +1,31 @@
namespace CGAL {
/*!
\ingroup kernel_predef
A typedef to a kernel which has the following properties:
<UL>
<LI>It uses Cartesian representation.
<LI>It supports constructions of points from <TT>double</TT> Cartesian
coordinates.
<LI>It provides exact geometric predicates, but inexact geometric
constructions.
</UL>
\models ::Kernel
\sa `CGAL::Exact_predicates_exact_constructions_kernel`
\sa `CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt`
\sa `CGAL::Cartesian`
*/
class Exact_predicates_inexact_constructions_kernel {
public:
/// @}
}; /* end Exact_predicates_inexact_constructions_kernel */
} /* end namespace CGAL */

View File

@ -0,0 +1,134 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
`Filtered_kernel_adaptor` is a kernel that uses the filtering technique
\cite cgal:bbp-iayed-01 to obtain a kernel with exact and efficient
predicate functors.
The geometric constructions are exactly those
of the kernel `CK`, which means that they are not necessarily exact.
In contrast to `Filtered_kernel`,
the global functions are those of `CK`.
\models ::Kernel
Example
--------------
The following example shows how to produce a kernel whose geometric
objects and constructions are those of `Simple_cartesian<double>`
The predicate functors of the kernel are exact, the global functions
are not.
\code
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Filtered_kernel.h>
typedef CGAL::Simple_cartesian<double> CK;
typedef CGAL::Filtered_kernel_adaptor<CK> K;
typedef K::Point_2 p(0,0), q(1,1), r(1,5);
CGAL::orientation(p,q,r); // not exact
typedef K::Orientation_2 orientation;
orientation(p,q,r); // exact
\endcode
*/
template< typename CK >
class Filtered_kernel_adaptor {
public:
/// @}
}; /* end Filtered_kernel_adaptor */
} /* end namespace CGAL */
namespace CGAL {
/*!
\ingroup PkgKernel23
`Filtered_kernel` is a kernel that uses the filtering technique based
on interval arithmetic from \cite cgal:bbp-iayed-01 to achieve
exact and efficient predicates. In addition, a few selected important
predicates are implemented using the formally proved, semi-static, filtering
techniques from \cite cgal:mp-fcafg-05.
The geometric constructions are exactly those
of the kernel `CK`, which means that they are not necessarily exact.
Parameters
--------------
The first parameter, `CK`, is the "Construction Kernel", namely the kernel
from which are taken the types of the geometric objects as well as the
geometric constructions.
The second parameter, `UseStaticFilters`, is a Boolean value which
activates or not an additional layer of semi-static filters. It defaults to
`true` (activated), unless the `CGAL_NO_STATIC_FILTERS` macro is
defined. This option is mostly for debugging and testing, there should be no
production use for deactivating static filters.
\models ::Kernel
Example
--------------
The following example shows how to produce a kernel whose geometric
objects and constructions are those of `Simple_cartesian<double>`
but the predicates are exact.
\code
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Filtered_kernel.h>
typedef CGAL::Simple_cartesian<double> CK;
typedef CGAL::Filtered_kernel<CK> K;
\endcode
Implementation
--------------
The implementation uses `CGAL::Filtered_predicate<EP, FP, C2E, C2F>` over
each predicate of the kernel traits interface. Additionally, faster static
filters may be used for a few selected critical predicates.
*/
template< typename CK >
class Filtered_kernel {
public:
/// \name Types
/// @{
/*!
The type of the exact kernel.
*/
typedef EK Exact_kernel;
/*!
The type of the approximate "filtering" kernel.
*/
typedef FK Approximate_kernel;
/// @}
/// \name Constants
/// @{
/*!
A Boolean value corresponding to the
second template argument. Tells whether static filters are provided.
*/
static const bool Has_static_filters;
/// @}
}; /* end Filtered_kernel */
} /* end namespace CGAL */

View File

@ -0,0 +1,80 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
`Filtered_predicate`is an adaptor for predicate function objects that allows
one to produce efficient and exact predicates. It is used to build
`CGAL::Filtered_kernel<CK>` and can be used for other
predicates too.
`EP` is the exact but supposedly slow predicate that is able to evaluate
the predicate correctly. It will be called only when the filtering predicate,
`FP`, cannot compute the correct result. This failure of `FP` must be
done by throwing an exception.
To convert the geometric objects that are the arguments of the predicate,
we use the function objects `C2E` and `C2F`, which must be of the form
`Cartesian_converter` or `Homogeneous_converter`.
Example
--------------
The following example defines an efficient and exact version of the
orientation predicate over three points using the Cartesian representation
with double coordinates and without reference counting
(`Simple_cartesian<double>::Point_2`).
Of course, the orientation predicate can already be found in the kernel, but
you can follow this example to filter your own predicates.
It uses the fast but inexact predicate based on interval arithmetic for
filtering and the slow but exact predicate based on multi-precision floats
when the filtering predicate fails.
\cgalexample{Filtered_predicate.cpp}
*/
template< typename EP, typename FP, typename C2E, typename C2F >
class Filtered_predicate {
public:
/// \name Types
/// @{
/*!
The return type of the function operators.
It must also be the same type as `EP::result_type`.
*/
typedef FP::result_type result_type;
/// @}
/// \name Creation
/// @{
/*!
Default constructor.
*/
Filtered_predicate<EP, FP, C2E, C2F>();
/// @}
/// \name Operations
/// Similar function operators are defined for up to 7 arguments.
/// @{
/*!
The unary function operator for unary predicates.
*/
template <class A1> result_type operator()(A1 a1);
/*!
The binary function operator for binary predicates.
*/
template <class A1, class A2>
result_type operator()(A1 a1, A2 a2);
/// @}
}; /* end Filtered_predicate */
} /* end namespace CGAL */

View File

@ -0,0 +1,49 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
A model for a `Kernel` using homogeneous coordinates to represent the
geometric objects. In order for `Homogeneous` to model Euclidean geometry
in \f$ E^2\f$ and/or \f$ E^3\f$, for some mathematical ring \f$ E\f$ (<I>e.g.</I>,
the integers \f$\mathbb{Z}\f$ or the rationals \f$\mathbb{Q}\f$), the template parameter `RingNumberType`
must model the mathematical ring \f$ E\f$. That is, the ring operations on this
number type must compute the mathematically correct results. If the number
type provided as a model for `RingNumberType` is only an approximation of a
ring (such as the built-in type `double`), then the geometry provided by
the kernel is only an approximation of Euclidean geometry.
\models ::Kernel
Implementation
--------------
This model of a kernel uses reference counting.
\sa `CGAL::Cartesian<FieldNumberType>`
\sa `CGAL::Simple_cartesian<FieldNumberType>`
\sa `CGAL::Simple_homogeneous<RingNumberType>`
*/
template< typename RingNumberType >
class Homogeneous {
public:
/// \name Types
/// @{
/*!
*/
typedef Quotient<RingNumberType> FT;
/*!
*/
typedef RingNumberType RT;
/// @}
}; /* end Homogeneous */
} /* end namespace CGAL */

View File

@ -0,0 +1,58 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
`Homogeneous_converter`converts objects from the kernel traits `K1` to
the kernel traits `K2`. Those traits must be of the form
`Homogeneous<RT1>` and `Homogeneous<RT2>` (or the equivalent with
`Simple_homogeneous`). It then provides the following operators to
convert objects from `K1` to `K2`.
The third template parameter `RT_Converter` is a function object that must
provide `K2::RT operator()(const K1::RT &n);` that
converts `n` to an `K2::RT` that has the same value.
The default value of this parameter is `CGAL::NT_converter<K1::RT, K2::RT>`,
which uses the conversion operator from
`K1::RT` to `K2::RT`.
Similarly, the fourth template parameter must provide
`K2::FT operator()(const K1::FT &n);` that
converts `n` to an `K2::FT` that has the same value. Its
default value is `CGAL::NT_converter<K1::FT, K2::FT>`.
\sa `CGAL::Homogeneous<RingNumberType>`
\sa `CGAL::Simple_homogeneous<RingNumberType>`
*/
template< typename K1, typename K2, typename RTConverter, typename FTConverter >
class Homogeneous_converter {
public:
/// \name Creation
/// @{
/*!
Default constructor.
*/
Homogeneous_converter<>();
/// @}
/// \name Operations
/// Similar operators as the one shown are defined for the other
/// kernel traits geometric types `Point_3`, `Vector_2`...
/// @{
/*!
returns a `K2::Point_2` which coordinates are those of `p`,
converted by `RTConverter`.
*/
K2::Point_2 operator()(const K1::Point_2&p);
/// @}
}; /* end Homogeneous_converter */
} /* end namespace CGAL */

View File

@ -0,0 +1,221 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object \f$ s\f$ of the data type `Iso_cuboid_3` is a
cuboid in the Euclidean space \f$ \E^3\f$ with edges parallel to the \f$ x\f$,
\f$ y\f$ and \f$ z\f$ axis of the coordinate system.
Although they are represented in a canonical form by only two
vertices, namely the lexicographically smallest and largest vertex
with respect to Cartesian \f$ xyz\f$ coordinates, we provide
functions for "accessing" the other vertices as well.
Iso-oriented cuboids and bounding boxes are quite similar. The
difference however is that bounding boxes have always double coordinates,
whereas the coordinate type of an iso-oriented cuboid is chosen by
the user.
\sa `Kernel::IsoCuboid_3`
*/
template< typename Kernel >
class Iso_cuboid_3 {
public:
/// \name Creation
/// @{
/*!
introduces an iso-oriented cuboid `c` with diagonal
opposite vertices \f$ p\f$ and \f$ q\f$. Note that the object is
brought in the canonical form.
*/
Iso_cuboid_3(const Point_3<Kernel> &p,
const Point_3<Kernel> &q);
/*!
introduces an iso-oriented cuboid `c` with diagonal
opposite vertices \f$ p\f$ and \f$ q\f$. The `int` argument value
is only used to distinguish the two overloaded functions.
\pre \f$ p.x()<=q.x()\f$, \f$ p.y()<=q.y()\f$ and \f$ p.z()<=q.z()\f$.
*/
Iso_cuboid_3(const Point_3<Kernel> &p,
const Point_3<Kernel> &q, int);
/*!
introduces an iso-oriented cuboid `c` whose
minimal \f$ x\f$ coordinate is the one of `left`, the
maximal \f$ x\f$ coordinate is the one of `right`, the
minimal \f$ y\f$ coordinate is the one of `bottom`, the
maximal \f$ y\f$ coordinate is the one of `top`, the
minimal \f$ z\f$ coordinate is the one of `far`, the
maximal \f$ z\f$ coordinate is the one of `close`.
*/
Iso_cuboid_3(const Point_3<Kernel> &left,
const Point_3<Kernel> &right,
const Point_3<Kernel> &bottom,
const Point_3<Kernel> &top,
const Point_3<Kernel> &far,
const Point_3<Kernel> &close);
/*!
introduces an iso-oriented cuboid `c` with diagonal
opposite vertices
(`min_hx/hw`, `min_hy/hw`, `min_hz/hw`) and
(`max_hx/hw`, `max_hy/hw`, `max_hz/hw`).
\pre `hw` \f$ \neq\f$ 0.
*/
Iso_cuboid_3(
const Kernel::RT& min_hx, const Kernel::RT& min_hy, const Kernel::RT& min_hz,
const Kernel::RT& max_hx, const Kernel::RT& max_hy, const Kernel::RT& max_hz,
const Kernel::RT& hw = RT(1));
/// @}
/// \name Operations
/// @{
/*!
Test for equality: two iso-oriented cuboid are equal, iff their
lower left and their upper right vertices are equal.
*/
bool operator==(const Iso_cuboid_3<Kernel> &c2) const;
/*!
Test for inequality.
*/
bool operator!=(const Iso_cuboid_3<Kernel> &c2) const;
/*!
returns the i'th vertex modulo 8 of `c`.
starting with the lower left vertex.
*/
Point_3<Kernel> vertex(int i) const;
/*!
returns `vertex(i)`, as indicated in the figure below:
\image html IsoCuboid.gif
*/
Point_3<Kernel> operator[](int i) const;
/*!
returns the smallest vertex of `c` (= `vertex(0)`).
*/
Point_3<Kernel> min() const;
/*!
returns the largest vertex of `c` (= `vertex(7)`).
*/
Point_3<Kernel> max() const;
/*!
returns smallest Cartesian
\f$ x\f$-coordinate in `c`.
*/
Kernel::FT xmin() const;
/*!
returns smallest Cartesian
\f$ y\f$-coordinate in `c`.
*/
Kernel::FT ymin() const;
/*!
returns smallest Cartesian
\f$ z\f$-coordinate in `c`.
*/
Kernel::FT zmin() const;
/*!
returns largest Cartesian
\f$ x\f$-coordinate in `c`.
*/
Kernel::FT xmax() const;
/*!
returns largest Cartesian
\f$ y\f$-coordinate in `c`.
*/
Kernel::FT ymax() const;
/*!
returns largest Cartesian
\f$ z\f$-coordinate in `c`.
*/
Kernel::FT zmax() const;
/*!
returns \f$ i\f$-th Cartesian coordinate of
the smallest vertex of `c`.
\pre \f$ 0 \leq i \leq2\f$.
*/
Kernel::FT min_coord(int i) const;
/*!
returns \f$ i\f$-th Cartesian coordinate of
the largest vertex of `c`.
\pre \f$ 0 \leq i \leq2\f$.
*/
Kernel::FT max_coord(int i) const;
/// @}
/// \name Predicates
/// @{
/*!
`c` is degenerate, if all vertices
are coplanar.
*/
bool is_degenerate() const;
/*!
returns either `ON_UNBOUNDED_SIDE`,
`ON_BOUNDED_SIDE`, or the constant
`ON_BOUNDARY`,
depending on where point \f$ p\f$ is.
*/
Bounded_side bounded_side(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on_boundary(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on_bounded_side(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on_unbounded_side(const Point_3<Kernel> &p) const;
/// @}
/// \name Miscellaneous
/// @{
/*!
returns the volume of `c`.
*/
Kernel::FT volume() const;
/*!
returns a bounding box containing `c`.
*/
Bbox_3 bbox() const;
/*!
returns the iso-oriented cuboid obtained by applying \f$ t\f$ on
the smallest and the largest of `c`.
\pre The angle at a rotation must be a multiple of \f$ \pi/2\f$, otherwise the resulting cuboid does not have the same size. Note that rotating about an arbitrary angle can even result in a degenerate iso-oriented cuboid.
*/
Iso_cuboid_3<Kernel> transform(const Aff_transformation_3<Kernel> &t) const;
/// @}
}; /* end Iso_cuboid_3 */
} /* end namespace CGAL */

View File

@ -0,0 +1,200 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object \f$ s\f$ of the data type `Iso_rectangle_2` is a
rectangle in the Euclidean plane \f$ \E^2\f$ with sides parallel to the \f$ x\f$ and
\f$ y\f$ axis of the coordinate system.
Although they are represented in a canonical form by only two
vertices, namely the lower left and the upper right vertex, we provide
functions for "accessing" the other vertices as well. The vertices
are returned in counterclockwise order.
Iso-oriented rectangles and bounding boxes are quite similar. The
difference however is that bounding boxes have always double coordinates,
whereas the coordinate type of an iso-oriented rectangle is chosen by
the user.
\sa `Kernel::IsoRectangle_2`
*/
template< typename Kernel >
class Iso_rectangle_2 {
public:
/// \name Creation
/// @{
/*!
introduces an iso-oriented rectangle `r` with diagonal
opposite vertices \f$ p\f$ and \f$ q\f$. Note that the object is
brought in the canonical form.
*/
Iso_rectangle_2(const Point_2<Kernel> &p,
const Point_2<Kernel> &q);
/*!
introduces an iso-oriented rectangle `r` with diagonal
opposite vertices \f$ p\f$ and \f$ q\f$. The `int` argument value
is only used to distinguish the two overloaded functions.
\pre \f$ p.x()<=q.x()\f$ and \f$ p.y()<=q.y()\f$.
*/
Iso_rectangle_2(const Point_2<Kernel> &p,
const Point_2<Kernel> &q,
int);
/*!
introduces an iso-oriented rectangle `r` whose
minimal \f$ x\f$ coordinate is the one of `left`, the
maximal \f$ x\f$ coordinate is the one of `right`, the
minimal \f$ y\f$ coordinate is the one of `bottom`, the
maximal \f$ y\f$ coordinate is the one of `top`.
*/
Iso_rectangle_2(const Point_2<Kernel> &left,
const Point_2<Kernel> &right,
const Point_2<Kernel> &bottom,
const Point_2<Kernel> &top);
/*!
introduces an iso-oriented rectangle `r` with diagonal
opposite vertices (`min_hx/hw`, `min_hy/hw`) and
(`max_hx/hw`, `max_hy/hw`).
\pre `hw` \f$ \neq\f$ 0.
*/
Iso_rectangle_2(const Kernel::RT& min_hx, const Kernel::RT& min_hy,
const Kernel::RT& max_hx, const Kernel::RT& max_hy,
const Kernel::RT& hw = RT(1));
/// @}
/// \name Operations
/// @{
/*!
Test for equality: two iso-oriented rectangles are equal, iff their
lower left and their upper right vertices are equal.
*/
bool operator==(const Iso_rectangle_2<Kernel> &r2) const;
/*!
Test for inequality.
*/
bool operator!=(const Iso_rectangle_2<Kernel> &r2) const;
/*!
returns the i'th vertex modulo 4 of `r` in counterclockwise order,
starting with the lower left vertex.
*/
Point_2<Kernel> vertex(int i) const;
/*!
returns `vertex(i)`.
*/
Point_2<Kernel> operator[](int i) const;
/*!
returns the lower left vertex of `r` (= `vertex(0)`).
*/
Point_2<Kernel> min() const;
/*!
returns the upper right vertex of `r` (= `vertex(2)`).
*/
Point_2<Kernel> max() const;
/*!
returns the \f$ x\f$ coordinate of lower left vertex of `r`.
*/
Kernel::FT xmin() const;
/*!
returns the \f$ y\f$ coordinate of lower left vertex of `r`.
*/
Kernel::FT ymin() const;
/*!
returns the \f$ x\f$ coordinate of upper right vertex of `r`.
*/
Kernel::FT xmax() const;
/*!
returns the \f$ y\f$ coordinate of upper right vertex of `r`.
*/
Kernel::FT ymax() const;
/*!
returns the \f$ i\f$'th Cartesian coordinate of the
lower left vertex of `r`.
\pre \f$ 0 \leq i \leq1\f$.
*/
Kernel::FT min_coord(int i) const;
/*!
returns the \f$ i\f$'th Cartesian coordinate of the
upper right vertex of `r`.
\pre \f$ 0 \leq i \leq1\f$.
*/
Kernel::FT max_coord(int i) const;
/// @}
/// \name Predicates
/// @{
/*!
`r` is degenerate, if all vertices
are collinear.
*/
bool is_degenerate() const;
/*!
returns either `ON_UNBOUNDED_SIDE`,
`ON_BOUNDED_SIDE`, or the constant
`ON_BOUNDARY`,
depending on where point \f$ p\f$ is.
*/
Bounded_side bounded_side(const Point_2<Kernel> &p) const;
/*!
*/
bool has_on_boundary(const Point_2<Kernel> &p) const;
/*!
*/
bool has_on_bounded_side(const Point_2<Kernel> &p) const;
/*!
*/
bool has_on_unbounded_side(const Point_2<Kernel> &p) const;
/// @}
/// \name Miscellaneous
/// @{
/*!
returns the area of `r`.
*/
Kernel::FT area() const;
/*!
returns a bounding box containing `r`.
*/
Bbox bbox() const;
/*!
returns the iso-oriented rectangle obtained by applying \f$ t\f$ on
the lower left and the upper right corner of `r`.
\pre The angle at a rotation must be a multiple of \f$ \pi/2\f$, otherwise the resulting rectangle does not have the same side length. Note that rotating about an arbitrary angle can even result in a degenerate iso-oriented rectangle.
*/
Iso_rectangle_2<Kernel> transform(const Aff_transformation_2<Kernel> &t) const;
/// @}
}; /* end Iso_rectangle_2 */
} /* end namespace CGAL */

View File

@ -0,0 +1,46 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
The class `Kernel_traits` provides access to the kernel model to
which the argument type `T` belongs. (Provided `T` belongs to
some kernel model.) The default implementation assumes there is a
local type `T::Kernel` referring to the kernel model of `T`.
If this type does not exist, a specialization of `Kernel_traits` can be
used to provide the desired information.
This class is, for example, useful in the following context. Assume
you want to write a generic function that accepts two points \f$ p\f$ and
\f$ q\f$ as argument and constructs the line segment between \f$ p\f$ and \f$ q\f$.
In order to specify the return type of this function, you need to know
what is the segment type corresponding to the Point type representing
\f$ p\f$ and \f$ q\f$. Using `Kernel_traits`, this can be done as follows.
\code
template < class Point >
typename Kernel_traits<Point>::Kernel::Segment
construct_segment(Point p, Point q)
{ ... }
\endcode
*/
template< typename T >
class Kernel_traits {
public:
/// \name Types
/// @{
/*!
If `T` is a type
`K::Point_2` of some kernel model `K`, then `Kernel` is
equal to `K`.
*/
typedef T::R Kernel;
/// @}
}; /* end Kernel_traits */
} /* end namespace CGAL */

View File

@ -0,0 +1,230 @@
/*!
\ingroup PkgKernel23
An object `l` of the data type `Line_2` is a directed
straight line in the two-dimensional Euclidean plane \f$ \E^2\f$. It is
defined by the set of points with Cartesian coordinates \f$ (x,y)\f$
that satisfy the equation
\f[ l:\; a\, x +b\, y +c = 0. \f]
The line splits \f$ \E^2\f$ in a <I>positive</I> and a <I>negative</I>
side. A point \f$ p\f$ with Cartesian coordinates
\f$ (px, py)\f$ is on the positive side of `l`, iff
\f$ a\, px + b\, py +c > 0\f$, it is
on the negative side of `l`, iff
\f$ a\, px + b\, py +c < 0\f$.
The positive side is to the left of `l`.
Example
--------------
Let us first define two Cartesian two-dimensional points in the Euclidean
plane \f$ \E^2\f$. Their
dimension and the fact that they are Cartesian is expressed by
the suffix `_2` and the representation type `Cartesian`.
<PRE>[cccbegin]
Point_2< Cartesian<double> > p(1.0,1.0), q(4.0,7.0);
</PRE>
To define a line \f$ l\f$ we write:
<PRE>
Line_2< Cartesian<double> > l(p,q);
</PRE>
\sa `Kernel::Line_2`
*/
template< typename Kernel >
class Line_2 {
public:
/// \name Creation
/// @{
/*!
introduces a line `l` with the line equation in Cartesian
coordinates \f$ ax +by +c = 0\f$.
*/
Line_2(const Kernel::RT &a, const Kernel::RT &b, const Kernel::RT &c);
/*!
introduces a line `l` passing through the points \f$ p\f$ and \f$ q\f$.
Line `l` is directed from \f$ p\f$ to \f$ q\f$.
*/
Line_2(const Point_2<Kernel> &p, const Point_2<Kernel> &q);
/*!
introduces a line `l` passing through point \f$ p\f$ with
direction \f$ d\f$.
*/
Line_2(const Point_2<Kernel> &p, const Direction_2<Kernel>&d);
/*!
introduces a line `l` passing through point \f$ p\f$ and
oriented by \f$ v\f$.
*/
Line_2(const Point_2<Kernel> &p, const Vector_2<Kernel>&v);
/*!
introduces a line `l` supporting the segment \f$ s\f$,
oriented from source to target.
*/
Line_2(const Segment_2<Kernel> &s);
/*!
introduces a line `l` supporting the ray \f$ r\f$,
with same orientation.
*/
Line_2(const Ray_2<Kernel> &r);
/// @}
/// \name Operations
/// @{
/*!
Test for equality: two lines are equal, iff they have a non
empty intersection and the same direction.
*/
bool operator==(const Line_2<Kernel> &h) const;
/*!
Test for inequality.
*/
bool operator!=(const Line_2<Kernel> &h) const;
/*!
returns the first coefficient of \f$ l\f$.
*/
Kernel::RT a() const;
/*!
returns the second coefficient of \f$ l\f$.
*/
Kernel::RT b() const;
/*!
returns the third coefficient of \f$ l\f$.
*/
Kernel::RT c() const;
/*!
returns an arbitrary point on `l`. It holds
`point(i) == point(j)`, iff `i==j`.
Furthermore, `l` is directed from `point(i)`
to `point(j)`, for all `i` \f$ <\f$ `j`.
*/
Point_2<Kernel> point(int i) const;
/*!
returns the orthogonal projection of \f$ p\f$ onto `l`.
*/
Point_2<Kernel> projection(const Point_2<Kernel> &p) const;
/*!
returns the \f$ x\f$-coordinate of the point at `l` with
given \f$ y\f$-coordinate.
\pre `l` is not horizontal.
*/
Kernel::FT x_at_y(const Kernel::FT &y) const;
/*!
returns the \f$ y\f$-coordinate of the point at `l` with
given \f$ x\f$-coordinate.
\pre `l` is not vertical.
*/
Kernel::FT y_at_x(const Kernel::FT &x) const;
/// @}
/// \name Predicates
/// @{
/*!
line `l` is degenerate, if the coefficients `a` and
`b` of the line equation are zero.
*/
bool is_degenerate() const;
/*!
*/
bool is_horizontal() const;
/*!
*/
bool is_vertical() const;
/*!
returns `ON_ORIENTED_BOUNDARY`,
`ON_NEGATIVE_SIDE`, or the constant
`ON_POSITIVE_SIDE`,
depending on the position of \f$ p\f$ relative to the oriented line `l`.
*/
Oriented_side oriented_side(const Point_2<Kernel> &p) const;
/// @}
/// \name Convenience Boolean Functions
/// @{
/*!
*/
bool has_on(const Point_2<Kernel> &p) const;
/*!
*/
bool has_on_positive_side(const Point_2<Kernel> &p) const;
/*!
*/
bool has_on_negative_side(const Point_2<Kernel> &p) const;
/// @}
/// \name Miscellaneous
/// @{
/*!
returns a vector having the direction of `l`.
*/
Vector_2<Kernel> to_vector() const;
/*!
returns the direction of `l`.
*/
Direction_2<Kernel> direction() const;
/*!
returns the line with opposite direction.
*/
Line_2<Kernel> opposite() const;
/*!
returns the line perpendicular to `l` and passing through \f$ p\f$,
where the direction is the direction of `l` rotated
counterclockwise by 90 degrees.
*/
Line_2<Kernel> perpendicular(const Point_2<Kernel> &p) const;
/*!
returns the line obtained by applying \f$ t\f$ on a point on `l`
and the direction of `l`.
*/
Line_2<Kernel> transform(const Aff_transformation_2<Kernel> &t) const;
/// @}
}; /* end Line_2 */
} /* end namespace CGAL */

View File

@ -0,0 +1,125 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object `l` of the data type `Line_3` is a directed
straight line in the three-dimensional Euclidean space \f$ \E^3\f$.
\sa `Kernel::Line_3`
*/
template< typename Kernel >
class Line_3 {
public:
/// \name Creation
/// @{
/*!
introduces a line `l` passing through the points \f$ p\f$ and \f$ q\f$.
Line `l` is directed from \f$ p\f$ to \f$ q\f$.
*/
Line_3(const Point_3<Kernel> &p, const Point_3<Kernel> &q);
/*!
introduces a line `l` passing through point \f$ p\f$ with
direction \f$ d\f$.
*/
Line_3(const Point_3<Kernel> &p, const Direction_3<Kernel>&d);
/*!
introduces a line `l` passing through point \f$ p\f$ and
oriented by \f$ v\f$.
*/
Line_3(const Point_3<Kernel> &p, const Vector_3<Kernel>&v);
/*!
returns the line supporting the segment \f$ s\f$,
oriented from source to target.
*/
Line_3(const Segment_3<Kernel> &s);
/*!
returns the line supporting the ray \f$ r\f$, with the
same orientation.
*/
Line_3(const Ray_3<Kernel> &r);
/// @}
/// \name Operations
/// @{
/*!
Test for equality: two lines are equal, iff they have a non
empty intersection and the same direction.
*/
bool operator==(const Line_3<Kernel> &h) const;
/*!
Test for inequality.
*/
bool operator!=(const Line_3<Kernel> &h) const;
/*!
returns the orthogonal projection of \f$ p\f$ on `l`.
*/
Point_3<Kernel> projection(const Point_3<Kernel> &p) const;
/*!
returns an arbitrary point on `l`. It holds
`point(i) = point(j)`, iff `i=j`.
*/
Point_3<Kernel> point(int i) const;
/// @}
/// \name Predicates
/// @{
/*!
returns `true` iff line `l` is degenerated to a point.
*/
bool is_degenerate() const;
/*!
returns `true` iff `p` lies on `l`.
*/
bool has_on(const Point_3<Kernel> &p) const;
/// @}
/// \name Miscellaneous
/// @{
/*!
returns the plane perpendicular to `l` passing through \f$ p\f$.
*/
Plane_3<Kernel> perpendicular_plane(const Point_3<Kernel> &p) const;
/*!
returns the line with opposite direction.
*/
Line_3<Kernel> opposite() const;
/*!
returns a vector having the same direction as `l`.
*/
Vector_3<Kernel> to_vector() const;
/*!
returns the direction of `l`.
*/
Direction_3<Kernel> direction() const;
/*!
returns the line obtained by applying \f$ t\f$ on a point on `l`
and the direction of `l`.
*/
Line_3<Kernel> transform(const Aff_transformation_3<Kernel> &t) const;
/// @}
}; /* end Line_3 */
} /* end namespace CGAL */

View File

@ -0,0 +1,64 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
\cgal defines a symbolic constant
`NULL_VECTOR` to construct zero length vectors.
`Null_vector` is the type of this constant.
\sa `CGAL::Vector_2<Kernel>`
\sa `CGAL::Vector_3<Kernel>`
*/
class Null_vector {
public:
}; /* end Null_vector */
} /* end namespace CGAL */
namespace CGAL {
/*!
\ingroup PkgKernel23
\cgal defines a symbolic constant
`ORIGIN` which denotes the point at the origin.
`Origin` is the type of this constant.
It is used in the conversion between points and vectors.
\sa `CGAL::Point_2<Kernel>`
\sa `CGAL::Point_3<Kernel>`
\sa `CGAL::Vector_2<Kernel>`
\sa `CGAL::Vector_3<Kernel>`
\sa `CGAL::operator+`
\sa `CGAL::operator-`
*/
class Origin {
public:
}; /* end Origin */
/*!
A symbolic constant which denotes the point at the origin. This
constant is used in the conversion between points and vectors.
Example
--------------
\code
Point_2< Cartesian<Exact_NT> > p(1.0, 1.0), q;
Vector2< Cartesian<Exact_NT> > v;
v = p - ORIGIN;
q = ORIGIN + v;
assert( p == q );
\endcode
\sa `CGAL::Point_2<Kernel>`
\sa `CGAL::Point_3<Kernel>`
*/
const Origin ORIGIN;
} /* end namespace CGAL */

View File

@ -0,0 +1,259 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object `h` of the data type `Plane_3` is an oriented
plane in the three-dimensional Euclidean space \f$ \E^3\f$. It is defined
by the set of points with Cartesian coordinates \f$ (x,y,z)\f$ that satisfy
the plane equation
\f[h :\; a\, x +b\, y +c\, z + d = 0.\f]
The plane splits \f$ \E^3\f$ in a <I>positive</I> and a <I>negative side</I>.
A point \f$ p\f$ with Cartesian coordinates \f$ (px, py, pz)\f$ is on the
positive side of `h`, iff \f$ a\, px +b\, py +c\, pz + d > 0\f$.
It is on the negative side, iff \f$ a\, px +b\, py\, +c\, pz + d < 0\f$.
\sa `Kernel::Plane_3`
*/
template< typename Kernel >
class Plane_3 {
public:
/// \name Creation
/// @{
/*!
creates a plane `h` defined by the equation
\f$ a\, px +b\, py +c\, pz + d = 0\f$.
Notice that `h` is degenerate if
\f$ a = b = c = 0\f$.
*/
Plane_3(const Kernel::RT &a,
const Kernel::RT &b,
const Kernel::RT &c,
const Kernel::RT &d);
/*!
creates a plane `h` passing through the points `p`,
`q` and `r`. The plane is oriented such that `p`,
`q` and `r` are oriented in a positive sense
(that is counterclockwise) when seen from the positive side of `h`.
Notice that `h` is degenerate if the points are collinear.
*/
Plane_3(const Point_3<Kernel> &p,
const Point_3<Kernel> &q,
const Point_3<Kernel> &r);
/*!
introduces a plane `h` that passes through point `p` and
that is orthogonal to `v`.
*/
Plane_3(const Point_3<Kernel> &p,
const Vector_3<Kernel> &v);
/*!
introduces a plane `h` that passes through point `p` and
that has as an orthogonal direction equal to `d`.
*/
Plane_3(const Point_3<Kernel> &p,
const Direction_3<Kernel>&d);
/*!
introduces a plane `h` that is defined through the three points
`l.point(0)`, `l.point(1)` and `p`.
*/
Plane_3(const Line_3<Kernel> &l,
const Point_3<Kernel> &p);
/*!
introduces a plane `h` that is defined through the three points
`r.point(0)`, `r.point(1)` and `p`.
*/
Plane_3(const Ray_3<Kernel> &r,
const Point_3<Kernel> &p);
/*!
introduces a plane `h` that is defined through the three points
`s.source()`, `s.target()` and `p`.
*/
Plane_3(const Segment_3<Kernel> &s,
const Point_3<Kernel> &p);
/*!
introduces a plane `h` that is defined as the plane containing
the circle.
*/
Plane_3(const Circle_3<Kernel> &c);
/// @}
/// \name Operations
/// @{
/*!
Test for equality: two planes are equal, iff they have a non
empty intersection and the same orientation.
*/
bool operator==(const Plane_3<Kernel> &h2) const;
/*!
Test for inequality.
*/
bool operator!=(const Plane_3<Kernel> &h2) const;
/*!
returns the first coefficient of `h`.
*/
Kernel::RT a() const;
/*!
returns the second coefficient of `h`.
*/
Kernel::RT b() const;
/*!
returns the third coefficient of `h`.
*/
Kernel::RT c() const;
/*!
returns the fourth coefficient of `h`.
*/
Kernel::RT d() const;
/*!
returns the line that is perpendicular to `h` and that
passes through point `p`. The line is oriented from
the negative to the positive side of `h`.
*/
Line_3<Kernel> perpendicular_line(const Point_3<Kernel> &p) const;
/*!
returns the orthogonal projection of \f$ p\f$ on `h`.
*/
Point_3<Kernel> projection(const Point_3<Kernel> &p) const;
/*!
returns the plane with opposite orientation.
*/
Plane_3<Kernel> opposite() const;
/*!
returns an arbitrary point on `h`.
*/
Point_3<Kernel> point() const;
/*!
returns a vector that is orthogonal to `h` and that
is directed to the positive side of `h`.
*/
Vector_3<Kernel> orthogonal_vector() const;
/*!
returns the direction that is orthogonal to `h` and that
is directed to the positive side of `h`.
*/
Direction_3<Kernel> orthogonal_direction() const;
/*!
returns a vector orthogonal to
`orthogonal_vector()`.
*/
Vector_3<Kernel> base1() const;
/*!
returns a vector that is both orthogonal to `base1()`,
and to `orthogonal_vector()`, and such that the result of
`orientation( point(), point() + base1(), point()+base2(), point() + orthogonal_vector() )` is positive.
*/
Vector_3<Kernel> base2() const;
/// @}
/// \name 2D Conversion
/// The following functions provide conversion between a plane and
/// \cgal's two-dimensional space. The transformation is affine, but
/// not necessarily an isometry. This means, the transformation
/// preserves combinatorics, but not distances.
/// @{
/*!
returns the image point of the projection of `p`
under an affine transformation, which maps `h` onto the
\f$ xy\f$-plane, with the \f$ z\f$-coordinate removed.
*/
Point_2<Kernel> to_2d(const Point_3<Kernel> &p) const;
/*!
returns a point \f$ q\f$, such that `to_2d( to_3d( p ))`
is equal to `p`.
*/
Point_3<Kernel> to_3d(const Point_2<Kernel> &p) const;
/// @}
/// \name Predicates
/// @{
/*!
returns either `ON_ORIENTED_BOUNDARY`, or
the constant `ON_POSITIVE_SIDE`, or the constant
`ON_NEGATIVE_SIDE`,
determined by the position of \f$ p\f$ relative to the oriented plane `h`.
*/
Oriented_side oriented_side(const Point_3<Kernel> &p) const;
/// @}
/// \name Convenience Boolean Functions
/// @{
/*!
*/
bool has_on(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on_positive_side(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on_negative_side(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on(const Line_3<Kernel> &l) const;
/*!
*/
bool has_on(const Circle_3<Kernel> &l) const;
/*!
Plane `h` is degenerate, if the coefficients `a`,
`b`, and `c` of the plane equation are zero.
*/
bool is_degenerate() const;
/// @}
/// \name Miscellaneous
/// @{
/*!
returns the plane obtained by applying \f$ t\f$ on a point of `h`
and the orthogonal direction of `h`.
*/
Plane_3<Kernel> transform(const Aff_transformation_3<Kernel> &t) const;
/// @}
}; /* end Plane_3 */
} /* end namespace CGAL */

View File

@ -0,0 +1,255 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object of the class `Point_2` is a point in the two-dimensional
Euclidean plane \f$ \E^2\f$.
Remember that `Kernel::RT` and `Kernel::FT` denote a
`RingNumberType` and a `FieldNumberType`, respectively. For the kernel
model `Cartesian<T>`, the two types are the same. For the
kernel model `Homogeneous<T>`, `Kernel::RT` is equal
to `T`, and `Kernel::FT` is equal to
`Quotient<T>`.
Operators
--------------
The following operations can be applied on points:
Example
--------------
The following declaration creates two points with
Cartesian double coordinates.
<PRE>
Point_2< Cartesian<double> > p, q(1.0, 2.0);
</PRE>
The variable <TT>p</TT> is uninitialized and should first be used on
the left hand side of an assignment.
<PRE>
p = q;
std::cout << p.x() << " " << p.y() << std::endl;
[cccend]</PRE>
\sa `Kernel::Point_2`
*/
template< typename Kernel >
class Point_2 {
public:
/// \name Types
/// @{
/*!
An iterator for enumerating the
Cartesian coordinates of a point.
*/
typedef Hidden_type Cartesian_const_iterator;
/// @}
/// \name Creation
/// @{
/*!
introduces a variable `p` with Cartesian coordinates
\f$ (0,0)\f$.
*/
Point_2(const Origin &ORIGIN);
/*!
introduces a point `p` initialized to \f$ (x,y)\f$.
*/
Point_2(int x, int y);
/*!
introduces a point `p` initialized to \f$ (x,y)\f$
provided `RT` supports construction from `double`.
*/
Point_2(double x, double y);
/*!
introduces a point `p` initialized to \f$ (hx/hw,hy/hw)\f$.
\pre `hw` \f$ \neq\f$ `Kernel::RT(0)`.
*/
Point_2(const Kernel::RT &hx, const Kernel::RT &hy, const Kernel::RT &hw = RT(1));
/*!
introduces a point `p` initialized to \f$ (x,y)\f$.
*/
Point_2(const Kernel::FT &x, const Kernel::FT &y);
/// @}
/// \name Operations
/// @{
/*!
Test for equality. Two points are equal, iff their \f$ x\f$ and \f$ y\f$
coordinates are equal. The point can be compared with `ORIGIN`.
*/
bool operator==(const Point_2<Kernel> &q) const;
/*!
Test for inequality. The point can be compared with `ORIGIN`.
*/
bool operator!=(const Point_2<Kernel> &q) const;
/// @}
/// \name Coordinate Access
/// There are two sets of coordinate access functions, namely to the
/// homogeneous and to the Cartesian coordinates. They can be used
/// independently from the chosen kernel model. Note that you do not
/// loose information with the homogeneous representation, because the
/// `FieldNumberType` is a quotient.
/// @{
/*!
returns the homogeneous \f$ x\f$ coordinate.
*/
Kernel::RT hx() const;
/*!
returns the homogeneous \f$ y\f$ coordinate.
*/
Kernel::RT hy() const;
/*!
returns the homogenizing coordinate.
*/
Kernel::RT hw() const;
/*!
returns the Cartesian \f$ x\f$ coordinate, that is \f$ hx/hw\f$.
*/
Kernel::FT x() const;
/*!
returns the Cartesian \f$ y\f$ coordinate, that is \f$ hy/hw\f$.
*/
Kernel::FT y() const;
/// @}
/// \name Convenience Operations
/// The following operations are for convenience and for compatibility
/// with higher dimensional points. Again they come in a Cartesian and
/// in a homogeneous flavor.
/// @{
/*!
returns the i'th homogeneous coordinate of `p`, starting with 0.
\pre \f$ 0\leq i \leq2\f$.
*/
Kernel::RT homogeneous(int i) const;
/*!
returns the i'th Cartesian coordinate of `p`, starting with 0.
\pre \f$ 0\leq i \leq1\f$.
*/
Kernel::FT cartesian(int i) const;
/*!
returns `cartesian(i)`.
\pre \f$ 0\leq i \leq1\f$.
*/
Kernel::FT operator[](int i) const;
/*!
returns an iterator to the Cartesian coordinates
of `p`, starting with the 0th coordinate.
*/
Cartesian_const_iterator cartesian_begin() const;
/*!
returns an off the end iterator to the Cartesian
coordinates of `p`.
*/
Cartesian_const_iterator cartesian_end() const;
/*!
returns the dimension (the constant 2).
*/
int dimension() const;
/*!
returns a bounding box containing `p`. Note that bounding boxes
are not parameterized with whatsoever.
*/
Bbox_2 bbox() const;
/*!
returns the point obtained by applying \f$ t\f$ on `p`.
*/
Point_2<Kernel> transform(const Aff_transformation_2<Kernel> &t) const;
/// @}
}; /* end Point_2 */
/*!
returns true iff `p` is lexicographically smaller than `q`,
i.e. either if `p.x() < q.x()` or if `p.x() == q.x()` and
`p.y() < q.y()`.
\relates Point_2
*/
bool operator<(const Point_2<Kernel> &p,
const Point_2<Kernel> &q);
/*!
returns true iff `p` is lexicographically greater than `q`.
\relates Point_2
*/
bool operator>(const Point_2<Kernel> &p,
const Point_2<Kernel> &q);
/*!
returns true iff `p` is lexicographically smaller or equal to `q`.
\relates Point_2
*/
bool operator<=(const Point_2<Kernel> &p,
const Point_2<Kernel> &q);
/*!
returns true iff `p` is lexicographically greater or equal to `q`.
\relates Point_2
*/
bool operator>=(const Point_2<Kernel> &p,
const Point_2<Kernel> &q);
/*!
returns the difference vector between `q` and `p`.
You can substitute `ORIGIN` for either `p` or `q`,
but not for both.
\relates Point_2
*/
Vector_2<Kernel> operator-(const Point_2<Kernel> &p,
const Point_2<Kernel> &q);
/*!
returns the point obtained by translating `p` by the
vector `v`.
\relates Point_2
*/
Point_2<Kernel> operator+(const Point_2<Kernel> &p,
const Vector_2<Kernel> &v);
/*!
returns the point obtained by translating `p` by the
vector -`v`.
\relates Point_2
*/
Point_2<Kernel> operator-(const Point_2<Kernel> &p,
const Vector_2<Kernel> &v);
} /* end namespace CGAL */

View File

@ -0,0 +1,244 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object of the class `Point_3` is a point in the three-dimensional
Euclidean space \f$ \E^3\f$.
Remember that `Kernel::RT` and `Kernel::FT` denote a
RingNumberType and a FieldNumberType, respectively. For the kernel
model `Cartesian<T>`, the two types are the same. For the
kernel model `Homogeneous<T>`, `Kernel::RT` is equal
to `T`, and `Kernel::FT` is equal to
`Quotient<T>`.
Operators
--------------
The following operations can be applied on points:
\sa `Kernel::Point_3`
*/
template< typename Kernel >
class Point_3 {
public:
/// \name Types
/// @{
/*!
An iterator for enumerating the
Cartesian coordinates of a point.
*/
typedef Hidden_type Cartesian_const_iterator;
/// @}
/// \name Creation
/// @{
/*!
introduces a point with Cartesian coordinates\f$ (0,0,0)\f$.
*/
Point_3(const Origin &ORIGIN);
/*!
introduces a point `p` initialized to \f$ (x,y,z)\f$.
*/
Point_3(int x, int y, int z);
/*!
introduces a point `p` initialized to \f$ (x,y,z)\f$
provided `RT` supports it.
*/
Point_3(double x, double y, double z);
/*!
introduces a point `p` initialized to \f$ (hx/hw,hy/hw, hz/hw)\f$.
\pre `hw` \f$ \neq\f$ 0.
*/
Point_3(const Kernel::RT &hx, const Kernel::RT &hy, const Kernel::RT &hz, const Kernel::RT &hw = RT(1));
/*!
introduces a point `p` initialized to \f$ (x,y,z)\f$.
*/
Point_3(const Kernel::FT &x, const Kernel::FT &y, const Kernel::FT &z);
/// @}
/// \name Operations
/// @{
/*!
Test for equality: Two points are equal, iff their \f$ x\f$, \f$ y\f$ and \f$ z\f$
coordinates are equal.
*/
bool operator==(const Point_3<Kernel> &q) const;
/*!
Test for inequality.
*/
bool operator!=(const Point_3<Kernel> &q) const;
/// @}
/// \name Coordinate Access
/// There are two sets of coordinate access functions, namely to the
/// homogeneous and to the Cartesian coordinates. They can be used
/// independently from the chosen kernel model. Note that you do not
/// loose information with the homogeneous representation, because the
/// FieldNumberType is a quotient.
/// @{
/*!
returns the homogeneous \f$ x\f$ coordinate.
*/
Kernel::RT hx() const;
/*!
returns the homogeneous \f$ y\f$ coordinate.
*/
Kernel::RT hy() const;
/*!
returns the homogeneous \f$ z\f$ coordinate.
*/
Kernel::RT hz() const;
/*!
returns the homogenizing coordinate.
*/
Kernel::RT hw() const;
/*!
returns the Cartesian \f$ x\f$ coordinate, that is \f$ hx/hw\f$.
*/
Kernel::FT x() const;
/*!
returns the Cartesian \f$ y\f$ coordinate, that is \f$ hy/hw\f$.
*/
Kernel::FT y() const;
/*!
returns the Cartesian \f$ z\f$ coordinate, that is \f$ hz/hw\f$.
*/
Kernel::FT z() const;
/// @}
/// \name Convenience Operators
/// The following operations are for convenience and for compatibility
/// with code for higher dimensional points. Again they come in a
/// Cartesian and in a homogeneous flavor.
/// @{
/*!
returns the i'th homogeneous coordinate of `p`, starting with 0.
\pre \f$ 0\leq i \leq3\f$.
*/
Kernel::RT homogeneous(int i) const;
/*!
returns the i'th Cartesian coordinate of `p`, starting with 0.
\pre \f$ 0\leq i \leq2\f$.
*/
Kernel::FT cartesian(int i) const;
/*!
returns `cartesian(i)`.
\pre \f$ 0\leq i \leq2\f$.
*/
Kernel::FT operator[](int i) const;
/*!
returns an iterator to the Cartesian coordinates
of `p`, starting with the 0th coordinate.
*/
Cartesian_const_iterator cartesian_begin() const;
/*!
returns an off the end iterator to the Cartesian
coordinates of `p`.
*/
Cartesian_const_iterator cartesian_end() const;
/*!
returns the dimension (the constant 3).
*/
int dimension() const;
/*!
returns a bounding box containing `p`.
*/
Bbox_3 bbox() const;
/*!
returns the point obtained by applying \f$ t\f$ on `p`.
*/
Point_3<Kernel> transform(const Aff_transformation_3<Kernel> &t) const;
/// @}
}; /* end Point_3 */
/*!
returns true iff `p` is lexicographically smaller than `q`
(the lexicographical order being defined on the Cartesian
coordinates).
\relates Point_3
*/
bool operator<(const Point_3<Kernel> &p,
const Point_3<Kernel> &q);
/*!
returns true iff `p` is lexicographically greater than `q`.
\relates Point_3
*/
bool operator>(const Point_3<Kernel> &p,
const Point_3<Kernel> &q);
/*!
returns true iff `p` is lexicographically smaller or equal to
`q`.
\relates Point_3
*/
bool operator<=(const Point_3<Kernel> &p,
const Point_3<Kernel> &q);
/*!
returns true iff `p` is lexicographically greater or equal to
`q`.
\relates Point_3
*/
bool operator>=(const Point_3<Kernel> &p,
const Point_3<Kernel> &q);
/*!
returns the difference vector between `q` and `p`.
You can substitute `ORIGIN` for either `p` or `q`,
but not for both.
\relates Point_3
*/
Vector_3<Kernel> operator-(const Point_3<Kernel> &p,
const Point_3<Kernel> &q);
/*!
returns the point obtained by translating `p` by the
vector `v`.
\relates Point_3
*/
Point_3<Kernel> operator+(const Point_3<Kernel> &p,
const Vector_3<Kernel> &v);
/*!
returns the point obtained by translating `p` by the
vector -`v`.
\relates Point_3
*/
Point_3<Kernel> operator-(const Point_3<Kernel> &p,
const Vector_3<Kernel> &v);
} /* end namespace CGAL */

View File

@ -0,0 +1,124 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
The class `Projection_traits_xy_3` is an adapter to apply 2D algorithms to the projections of 3D data on the `xy`-plane.
\cgal provides also predefined geometric traits classes
`Projection_traits_yz_3<K>` and
`Projection_traits_xz_3<K>` to
deal with projections on the
`zx`- and the `zy`-plane,
respectively.
Parameters
--------------
The template parameter `K` has to
be instantiated by a model of the `Kernel` concept.
`Projection_traits_xy_3` uses types
and predicates defined in `K`.
\models The class is a model of several 2D triangulation traits class concepts,
except that it does not provide the type and constructors
required to build the dual Voronoi diagram.
\models ::PolygonTraits_2
\models ::ConvexHullTraits_2
\models ::TriangulationTraits_2
\models ::DelaunayTriangulationTraits_2
\models ::ConstrainedTriangulationTraits_2
\models ::PolygonTraits_2
\models ::ConvexHullTraits_2
*/
template< typename K >
class Projection_traits_xy_3 {
public:
/// \name Types
/// @{
/*!
*/
typedef Point_3<K> Point_2;
/*!
*/
typedef Segment_3<K> Segment_2;
/*!
*/
typedef Triangle_3<K> Triangle_2;
/*!
*/
typedef Line_3<K> Line_2;
/*!
*/
typedef K::Object_3 Object_2;
/// @}
/// \name Functors
/// The functors provided by this class are those listed in the
/// concepts, except that it does not provide the type and
/// constructors required to build the dual Voronoi diagram. The
/// functors operate on the 2D projection of their arguments. They
/// come with preconditions that projections of the arguments are
/// non-degenerate, eg. a line segment does not project on a single
/// point, two points do not project on the same point, etc. In the
/// following, we specify the choice of the `z`-coordinate in case a
/// new point is constructed.
/// @{
/*!
A construction object.
Provides the operator :
`Object_2 operator()(Segment_2 s1, Segment_2 s2);`
which returns a 3D object whose projection on the xy-plane
is the intersection of the projections of `s1` and `s2`.
If non empty, the returned object is either a segment or a point.
Its embedding in 3D is computed as the interpolation
between `s1` and `s2`,
meaning that any point `p` of the returned object
is the midpoint of segment `p1p2` where `p1` and `p2` are the two points of `s1` and `s2` respectively, both projecting on `p`.
\pre The projection of `s1` and the projection of `s2` are non-degenerate `2D` segments.
*/
typedef Hidden_type Intersect_2;
/// @}
/// \name Creation
/// @{
/*!
default constructor.
*/
Projection_traits_xy_3();
/*!
Copy constructor.
*/
Projection_traits_xy_3(
Projection_traits_xy_3 tr);
/*!
Assignment operator.
*/
Projection_traits_xy_3 operator=(Projection_traits_xy_3 tr);
/// @}
}; /* end Projection_traits_xy_3 */
} /* end namespace CGAL */

View File

@ -0,0 +1,141 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object `r` of the data type `Ray_2` is a directed
straight ray in the two-dimensional Euclidean plane \f$ \E^2\f$. It starts
in a point called the <I>source</I> of `r` and goes to infinity.
\sa `Kernel::Ray_2`
*/
template< typename Kernel >
class Ray_2 {
public:
/// \name Creation
/// @{
/*!
introduces a ray `r`
with source \f$ p\f$ and passing through point \f$ q\f$.
*/
Ray_2(const Point_2<Kernel> &p, const Point_2<Kernel>&q);
/*!
introduces a ray `r` starting at source \f$ p\f$ with
direction \f$ d\f$.
*/
Ray_2(const Point_2<Kernel> &p, const Direction_2<Kernel> &d);
/*!
introduces a ray `r` starting at source \f$ p\f$ with
the direction of \f$ v\f$.
*/
Ray_2(const Point_2<Kernel> &p, const Vector_2<Kernel> &v);
/*!
introduces a ray `r` starting at source \f$ p\f$ with
the same direction as \f$ l\f$.
*/
Ray_2(const Point_2<Kernel> &p, const Line_2<Kernel> &l);
/// @}
/// \name Operations
/// @{
/*!
Test for equality: two rays are equal, iff they have the same
source and the same direction.
*/
bool operator==(const Ray_2<Kernel> &h) const;
/*!
Test for inequality.
*/
bool operator!=(const Ray_2<Kernel> &h) const;
/*!
returns the source of `r`.
*/
Point_2<Kernel> source() const;
/*!
returns a point on `r`. `point(0)` is the source,
`point(i)`, with \f$ i>0\f$, is different from the
source. \pre \f$ i \geq0\f$.
*/
Point_2<Kernel> point(int i) const;
/*!
returns the direction of `r`.
*/
Direction_2<Kernel> direction() const;
/*!
returns a vector giving the direction of `r`.
*/
Vector_2<Kernel> to_vector() const;
/*!
returns the line supporting `r` which has the same direction.
*/
Line_2<Kernel> supporting_line() const;
/*!
returns the ray with the same source and the opposite direction.
*/
Ray_2<Kernel> opposite() const;
/// @}
/// \name Predicates
/// @{
/*!
ray `r` is degenerate, if the source and the second defining
point fall together (that is if the direction is degenerate).
*/
bool is_degenerate() const;
/*!
*/
bool is_horizontal() const;
/*!
*/
bool is_vertical() const;
/*!
A point is on `r`, iff it is equal to the source
of `r`, or if it is in the interior of `r`.
*/
bool has_on(const Point_2<Kernel> &p) const;
/*!
checks if point \f$ p\f$ is on `r`. This function is faster
than function `has_on()` if the precondition
checking is disabled.
\pre \f$ p\f$ is on the supporting line of `r`.
*/
bool collinear_has_on(const Point_2<Kernel> &p) const;
/// @}
/// \name Miscellaneous
/// @{
/*!
returns the ray obtained by applying \f$ t\f$ on the source
and on the direction of `r`.
*/
Ray_2<Kernel> transform(const Aff_transformation_2<Kernel> &t) const;
/// @}
}; /* end Ray_2 */
} /* end namespace CGAL */

View File

@ -0,0 +1,113 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object `r` of the data type `Ray_3` is a directed
straight ray in the three-dimensional Euclidean space \f$ \E^3\f$. It starts
in a point called the <I>source</I> of `r` and it goes to infinity.
\sa `Kernel::Ray_3`
*/
template< typename Kernel >
class Ray_3 {
public:
/// \name Creation
/// @{
/*!
introduces a ray `r`
with source \f$ p\f$ and passing through point \f$ q\f$.
*/
Ray_3(const Point_3<Kernel> &p, const Point_3<Kernel> &q);
/*!
introduces a ray `r` with source \f$ p\f$ and with
direction \f$ d\f$.
*/
Ray_3(const Point_3<Kernel> &p, const Direction_3<Kernel> &d);
/*!
introduces a ray `r` with source \f$ p\f$ and with
a direction given by \f$ v\f$.
*/
Ray_3(const Point_3<Kernel> &p, const Vector_3<Kernel> &v);
/*!
introduces a ray `r` starting at source \f$ p\f$ with
the same direction as \f$ l\f$.
*/
Ray_3(const Point_3<Kernel> &p, const Line_3<Kernel> &l);
/// @}
/// \name Operations
/// @{
/*!
Test for equality: two rays are equal, iff they have the same
source and the same direction.
*/
bool operator==(const Ray_3<Kernel> &h) const;
/*!
Test for inequality.
*/
bool operator!=(const Ray_3<Kernel> &h) const;
/*!
returns the source of `r`
*/
Point_3<Kernel> source() const;
/*!
returns a point on `r`. `point(0)` is the source.
`point(i)`, with \f$ i>0\f$, is different from the
source. \pre \f$ i \geq0\f$.
*/
Point_3<Kernel> point(int i) const;
/*!
returns the direction of `r`.
*/
Direction_3<Kernel> direction() const;
/*!
returns a vector giving the direction of `r`.
*/
Vector_3<Kernel> to_vector() const;
/*!
returns the line supporting `r` which has the same direction.
*/
Line_3<Kernel> supporting_line() const;
/*!
returns the ray with the same source and the opposite direction.
*/
Ray_3<Kernel> opposite() const;
/*!
ray `r` is degenerate, if the source and the second defining
point fall together (that is if the direction is degenerate).
*/
bool is_degenerate() const;
/*!
A point is on `r`, iff it is equal to the source
of `r`, or if it is in the interior of `r`.
*/
bool has_on(const Point_3<Kernel> &p) const;
/*!
returns the ray obtained by applying \f$ t\f$ on the source
and on the direction of `r`.
*/
Ray_3<Kernel> transform(const Aff_transformation_3<Kernel> &t) const;
/// @}
}; /* end Ray_3 */
} /* end namespace CGAL */

View File

@ -0,0 +1,166 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object \f$ s\f$ of the data type `Segment_2` is a directed
straight line segment in the two-dimensional Euclidean plane \f$ \E^2\f$, i.e. a
straight line segment \f$ [p,q]\f$ connecting two points \f$ p,q \in \R^2\f$.
The segment is topologically closed, i.e. the end
points belong to it. Point \f$ p\f$ is called the <I>source</I> and \f$ q\f$
is called the <I>target</I> of \f$ s\f$. The length of \f$ s\f$ is the
Euclidean distance between \f$ p\f$ and \f$ q\f$. Note that there is only a function
to compute the square of the length, because otherwise we had to
perform a square root operation which is not defined for all
number types, which is expensive, and may not be exact.
\sa `Kernel::Segment_2`
*/
template< typename Kernel >
class Segment_2 {
public:
/// \name Creation
/// @{
/*!
introduces a segment `s` with source \f$ p\f$
and target \f$ q\f$. The segment is directed from the source towards
the target.
*/
Segment_2(const Point_2<Kernel> &p, const Point_2<Kernel> &q);
/// @}
/// \name Operations
/// @{
/*!
Test for equality: Two segments are equal, iff their sources and
targets are equal.
*/
bool operator==(const Segment_2<Kernel> &q) const;
/*!
Test for inequality.
*/
bool operator!=(const Segment_2<Kernel> &q) const;
/*!
returns the source of `s`.
*/
Point_2<Kernel> source() const;
/*!
returns the target of `s`.
*/
Point_2<Kernel> target() const;
/*!
returns the point of `s` with lexicographically smallest coordinate.
*/
Point_2<Kernel> min() const;
/*!
returns the point of `s` with lexicographically largest coordinate.
*/
Point_2<Kernel> max() const;
/*!
returns source or target of `s`: `vertex(0)` returns
the source of `s`, `vertex(1)` returns the target of `s`.
The parameter `i` is taken modulo 2, which gives
easy access to the other vertex.
*/
Point_2<Kernel> vertex(int i) const;
/*!
returns `vertex(i)`.
*/
Point_2<Kernel> point(int i) const;
/*!
returns `vertex(i)`.
*/
Point_2<Kernel> operator[](int i) const;
/*!
returns the squared length of `s`.
*/
Kernel::FT squared_length() const;
/*!
returns the direction from source to target of `s`.
*/
Direction_2<Kernel> direction() const;
/*!
returns the vector `s`.`target()` - `s`.`source()`.
*/
Vector_2<Kernel> to_vector() const;
/*!
returns a segment with source and target point interchanged.
*/
Segment_2<Kernel> opposite() const;
/*!
returns the line \f$ l\f$ passing through `s`. Line \f$ l\f$ has the
same orientation as segment `s`.
*/
Line_2<Kernel> supporting_line() const;
/// @}
/// \name Predicates
/// @{
/*!
segment `s` is degenerate, if source and target are equal.
*/
bool is_degenerate() const;
/*!
*/
bool is_horizontal() const;
/*!
*/
bool is_vertical() const;
/*!
A point is on `s`, iff it is equal to the source or target
of `s`, or if it is in the interior of `s`.
*/
bool has_on(const Point_2<Kernel> &p) const;
/*!
checks if point \f$ p\f$ is on segment `s`. This function is faster
than function `has_on()`.
\pre \f$ p\f$ is on the supporting line of `s`.
*/
bool collinear_has_on(const Point_2<Kernel> &p) const;
/// @}
/// \name Miscellaneous
/// @{
/*!
returns a bounding box containing `s`.
*/
Bbox_2 bbox() const;
/*!
returns the segment obtained by applying \f$ t\f$ on the source
and the target of `s`.
*/
Segment_2<Kernel> transform(const Aff_transformation_2<Kernel> &t) const;
/// @}
}; /* end Segment_2 */
} /* end namespace CGAL */

View File

@ -0,0 +1,140 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object \f$ s\f$ of the data type `Segment_3` is a directed
straight line segment in the three-dimensional Euclidean space \f$ \E^3\f$, i.e. a
straight line segment \f$ [p,q]\f$ connecting two points \f$ p,q \in
\R^3\f$. The segment is topologically closed, i.e. the end
points belong to it. Point \f$ p\f$ is called the <I>source</I> and \f$ q\f$
is called the <I>target</I> of \f$ s\f$. The length of \f$ s\f$ is the
Euclidean distance between \f$ p\f$ and \f$ q\f$. Note that there is only a function
to compute the square of the length, because otherwise we had to
perform a square root operation which is not defined for all
number types, which is expensive, and may not be exact.
\sa `Kernel::Segment_3`
*/
template< typename Kernel >
class Segment_3 {
public:
/// \name Creation
/// @{
/*!
introduces a segment `s` with source \f$ p\f$
and target \f$ q\f$. It is directed from the source towards
the target.
*/
Segment_3(const Point_3<Kernel> &p, const Point_3<Kernel> &q);
/// @}
/// \name Operations
/// @{
/*!
Test for equality: Two segments are equal, iff their sources and
targets are equal.
*/
bool operator==(const Segment_3<Kernel> &q) const;
/*!
Test for inequality.
*/
bool operator!=(const Segment_3<Kernel> &q) const;
/*!
returns the source of `s`.
*/
Point_3<Kernel> source() const;
/*!
returns the target of `s`.
*/
Point_3<Kernel> target() const;
/*!
returns the point of `s` with smallest coordinate (lexicographically).
*/
Point_3<Kernel> min() const;
/*!
returns the point of `s` with largest coordinate (lexicographically).
*/
Point_3<Kernel> max() const;
/*!
returns source or target of `s`: `vertex(0)` returns
the source, `vertex(1)` returns the target.
The parameter `i` is taken modulo 2, which gives
easy access to the other vertex.
*/
Point_3<Kernel> vertex(int i) const;
/*!
returns `vertex(i)`.
*/
Point_3<Kernel> point(int i) const;
/*!
returns `vertex(i)`.
*/
Point_3<Kernel> operator[](int i) const;
/*!
returns the squared length of `s`.
*/
Kernel::FT squared_length() const;
/*!
returns the vector `s`.`target()` - `s`.`source()`.
*/
Vector_3<Kernel> to_vector() const;
/*!
returns the direction from source to target.
*/
Direction_3<Kernel> direction() const;
/*!
returns a segment with source and target interchanged.
*/
Segment_3<Kernel> opposite() const;
/*!
returns the line \f$ l\f$ passing through `s`. Line \f$ l\f$ has the
same orientation as segment `s`, that is
from the source to the target of `s`.
*/
Line_3<Kernel> supporting_line() const;
/*!
segment `s` is degenerate, if source and target fall together.
*/
bool is_degenerate() const;
/*!
A point is on `s`, iff it is equal to the source or target
of `s`, or if it is in the interior of `s`.
*/
bool has_on(const Point_3<Kernel> &p) const;
/*!
returns a bounding box containing `s`.
*/
Bbox_3 bbox() const;
/*!
returns the segment obtained by applying \f$ t\f$ on the source
and the target of `s`.
*/
Segment_3<Kernel> transform(const Aff_transformation_3<Kernel> &t) const;
/// @}
}; /* end Segment_3 */
} /* end namespace CGAL */

View File

@ -0,0 +1,51 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
A model for a `Kernel` using Cartesian coordinates to represent the
geometric objects. In order for `Simple_cartesian` to model Euclidean geometry
in \f$ E^2\f$ and/or \f$ E^3\f$, for some mathematical field \f$ E\f$ (<I>e.g.</I>,
the rationals \f$\mathbb{Q}\f$ or the reals \f$\mathbb{R}\f$), the template parameter `FieldNumberType`
must model the mathematical field \f$ E\f$. That is, the field operations on this
number type must compute the mathematically correct results. If the number
type provided as a model for `FieldNumberType` is only an approximation of a
field (such as the built-in type `double`), then the geometry provided by
the kernel is only an approximation of Euclidean geometry.
\models ::Kernel
Implementation
--------------
In contrast to `Cartesian`, no reference counting
is used internally. This eases debugging, but may slow down algorithms
that copy objects intensively.
\sa `CGAL::Cartesian<FieldNumberType>`
\sa `CGAL::Homogeneous<RingNumberType>`
\sa `CGAL::Simple_homogeneous<RingNumberType>`
*/
template< typename FieldNumberType >
class Simple_cartesian {
public:
/// \name Types
/// @{
/*!
*/
typedef FieldNumberType FT;
/*!
*/
typedef FieldNumberType RT;
/// @}
}; /* end Simple_cartesian */
} /* end namespace CGAL */

View File

@ -0,0 +1,51 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
A model for a `Kernel` using homogeneous coordinates to represent the
geometric objects. In order for `Simple_homogeneous` to model Euclidean geometry
in \f$ E^2\f$ and/or \f$ E^3\f$, for some mathematical ring \f$ E\f$ (<I>e.g.</I>,
the integers \f$\mathbb{Z}\f$ or the rationals \f$\mathbb{Q}\f$), the template parameter `RingNumberType`
must model the mathematical ring \f$ E\f$. That is, the ring operations on this
number type must compute the mathematically correct results. If the number
type provided as a model for `RingNumberType` is only an approximation of a
ring (such as the built-in type `double`), then the geometry provided by
the kernel is only an approximation of Euclidean geometry.
\models ::Kernel
Implementation
--------------
In contrast to `Homogeneous`, no reference counting
is used internally. This eases debugging, but may slow down algorithms
that copy objects intensively, or slightly speed up others.
\sa `CGAL::Cartesian<FieldNumberType>`
\sa `CGAL::Homogeneous<RingNumberType>`
\sa `CGAL::Simple_cartesian<FieldNumberType>`
*/
template< typename RingNumberType >
class Simple_homogeneous {
public:
/// \name Types
/// @{
/*!
*/
typedef Quotient<RingNumberType> FT;
/*!
*/
typedef RingNumberType RT;
/// @}
}; /* end Simple_homogeneous */
} /* end namespace CGAL */

View File

@ -0,0 +1,224 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object of type `Sphere_3` is a sphere in the
three-dimensional Euclidean space \f$ \E^3\f$. The sphere is oriented, i.e.
its boundary has clockwise or counterclockwise orientation. The
boundary splits \f$ \E^3\f$ into a positive and a negative side, where the
positive side is to the left of the boundary. The boundary also
splits \f$ \E^3\f$ into a bounded and an unbounded side. Note that the
sphere can be degenerated, i.e. the squared radius may be zero.
\sa `Kernel::Sphere_3`
*/
template< typename Kernel >
class Sphere_3 {
public:
/// \name Creation
/// @{
/*!
introduces a variable `c` of type `Sphere_3`.
It is initialized to the sphere with center `center`,
squared radius `squared_radius` and orientation
`orientation`.
\pre `orientation` \f$ \neq\f$ `COPLANAR`, and furthermore, `squared_radius` \f$ \geq\f$ 0.
*/
Sphere_3( Point_3<Kernel> const& center,
Kernel::FT const& squared_radius,
Orientation const& orientation = COUNTERCLOCKWISE);
/*!
introduces a variable `c` of type `Sphere_3`.
It is initialized to the unique sphere which passes through
the points `p`, `q`, `r` and `s`. The orientation of
the sphere is the orientation of the point quadruple `p`,
`q`, `r`, `s`.
\pre `p`, `q`, `r`, and `s` are not coplanar.
*/
Sphere_3( Point_3<Kernel> const& p,
Point_3<Kernel> const& q,
Point_3<Kernel> const& r,
Point_3<Kernel> const& s);
/*!
introduces a variable `c` of type `Sphere_3`.
It is initialized to the smallest sphere which passes through
the points `p`, `q`, and `r`. The orientation of
the sphere is `o`. \pre `o` is not `COPLANAR`.
*/
Sphere_3( Point_3<Kernel> const& p,
Point_3<Kernel> const& q,
Point_3<Kernel> const& r,
const Orientation& o = COUNTERCLOCKWISE);
/*!
introduces a variable `c` of type `Sphere_3`.
It is initialized to the smallest sphere which passes through
the points `p` and `q`. The orientation of
the sphere is `o`. \pre `o` is not `COPLANAR`.
*/
Sphere_3( Point_3<Kernel> const& p,
Point_3<Kernel> const& q,
const Orientation& o = COUNTERCLOCKWISE);
/*!
introduces a variable `c` of type `Sphere_3`.
It is initialized to the sphere with center `center`, squared
radius zero and orientation `orientation`.
\pre `orientation` \f$ \neq\f$ `COPLANAR`.
\post `c`.`is_degenerate()` = `true`.
*/
Sphere_3( Point_3<Kernel> const& center,
Orientation const& orientation = COUNTERCLOCKWISE);
/*!
introduces a variable `c` of type `Sphere_3`.
It is initialized to the diametral sphere of the circle.
*/
Sphere_3( Circle_3<Kernel> const& c );
/// @}
/// \name Access Functions
/// @{
/*!
returns the center of `c`.
*/
Point_3<Kernel> const& center( ) const;
/*!
returns the squared radius of `c`.
*/
Kernel::FT const& squared_radius( ) const;
/*!
returns the orientation of `c`.
*/
Orientation const& orientation( ) const;
/*!
returns `true`, iff `c` and `sphere2` are equal,
i.e. if they have the same center, same squared radius and
same orientation.
*/
bool operator == ( Sphere_3<Kernel> const& sphere2) const;
/*!
returns `true`, iff `c` and `sphere2` are not equal.
*/
bool operator != ( Sphere_3<Kernel> const& sphere2) const;
/// @}
/// \name Predicates
/// @{
/*!
returns `true`, iff `c` is degenerate, i.e. if `c` has squared radius zero.
*/
bool is_degenerate( ) const;
/*!
returns either the constant `ON_ORIENTED_BOUNDARY`,
`ON_POSITIVE_SIDE`, or `ON_NEGATIVE_SIDE`,
iff `p` lies on the boundary, properly on the
positive side, or properly on the negative side
of `c`, resp.
*/
Oriented_side
oriented_side( Point_3<Kernel> const& p) const;
/*!
returns `ON_BOUNDED_SIDE`,
`ON_BOUNDARY`, or `ON_UNBOUNDED_SIDE`
iff `p` lies properly inside, on the boundary, or properly
outside of `c`, resp.
*/
Bounded_side
bounded_side( Point_3<Kernel> const& p) const;
/*!
*/
bool has_on_positive_side(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on_negative_side(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on_boundary(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on_bounded_side(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on_unbounded_side(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on(const Circle_3<Kernel> &p) const;
/// @}
/// \name Miscellaneous
/// @{
/*!
returns the sphere with the same center and squared radius as
`c` but with opposite orientation.
*/
Sphere_3<Kernel> opposite() const;
/*!
returns the sphere obtained by applying \f$ at\f$ on `c`.
\pre `at` is an orthogonal transformation.
*/
Sphere_3<Kernel> orthogonal_transform(
Aff_transformation_3<Kernel> const& at) const;
/*!
returns a bounding box containing `c`.
*/
Bbox_3 bbox() const;
/// @}
}; /* end Sphere_3 */
} /* end namespace CGAL */

View File

@ -0,0 +1,144 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object \f$ t\f$ of the class `Tetrahedron_3` is an oriented
tetrahedron in the three-dimensional Euclidean space \f$ \E^3\f$.
It is defined by four vertices \f$ p_0\f$, \f$ p_1\f$, \f$ p_2\f$ and \f$ p_3\f$.
The orientation of a tetrahedron is the orientation of its four
vertices. That means it is positive when \f$ p_3\f$ is on the positive
side of the plane defined by \f$ p_0\f$, \f$ p_1\f$ and \f$ p_2\f$.
The tetrahedron itself splits the space \f$ \E^3\f$ in a <I>positive</I> and
a <I>negative</I> side.
The boundary of a tetrahedron splits the space in two open regions, a
bounded one and an unbounded one.
\sa `Kernel::Tetrahedron_3`
*/
template< typename Kernel >
class Tetrahedron_3 {
public:
/// \name Creation
/// @{
/*!
introduces a tetrahedron `t` with vertices \f$ p_0\f$, \f$ p_1\f$, \f$ p_2\f$ and \f$ p_3\f$.
*/
Tetrahedron_3(const Point_3<Kernel> &p0,
const Point_3<Kernel> &p1,
const Point_3<Kernel> &p2,
const Point_3<Kernel> &p3);
/// @}
/// \name Operations
/// @{
/*!
Test for equality: two tetrahedra `t` and `t2` are equal,
iff `t` and `t2` have the same orientation and
their sets (not sequences) of vertices are equal.
*/
bool operator==(const Tetrahedron_3<Kernel> &t2) const;
/*!
Test for inequality.
*/
bool operator!=(const Tetrahedron_3<Kernel> &t2) const;
/*!
returns the i'th vertex modulo 4 of `t`.
*/
Point_3<Kernel> vertex(int i) const;
/*!
returns `vertex(int i)`.
*/
Point_3<Kernel> operator[](int i) const;
/// @}
/// \name Predicates
/// @{
/*!
Tetrahedron `t` is degenerate, if the vertices are coplanar.
*/
bool is_degenerate() const;
/*!
*/
Orientation orientation() const;
/*!
\pre : `t` is not degenerate.
*/
Oriented_side oriented_side(const Point_3<Kernel> &p) const;
/*!
\pre : `t` is not degenerate.
*/
Bounded_side bounded_side(const Point_3<Kernel> &p) const;
/// @}
/// \name Convencience Boolean Functions
/// @{
/*!
*/
bool has_on_positive_side(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on_negative_side(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on_boundary(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on_bounded_side(const Point_3<Kernel> &p) const;
/*!
*/
bool has_on_unbounded_side(const Point_3<Kernel> &p) const;
/// @}
/// \name Miscellaneous
/// @{
/*!
returns the signed volume of `t`.
*/
Kernel::FT volume() const;
/*!
returns a bounding box containing `t`.
*/
Bbox_3 bbox() const;
/*!
returns the tetrahedron obtained by applying \f$ at\f$ on the three
vertices of `t`.
*/
Tetrahedron_3<Kernel> transform(const Aff_transformation_3<Kernel> &at) const;
/// @}
}; /* end Tetrahedron_3 */
} /* end namespace CGAL */

View File

@ -0,0 +1,152 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object \f$ t\f$ of the class `Triangle_2` is a triangle
in the two-dimensional Euclidean plane \f$ \E^2\f$.
Triangle \f$ t\f$ 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.
\sa `Kernel::Triangle_2`
*/
template< typename Kernel >
class Triangle_2 {
public:
/// \name Creation
/// @{
/*!
introduces a triangle `t` with vertices \f$ p\f$, \f$ q\f$ and \f$ r\f$.
*/
Triangle_2(const Point_2<Kernel> &p,
const Point_2<Kernel> &q,
const Point_2<Kernel> &r);
/// @}
/// \name Operations
/// @{
/*!
Test for equality: two triangles are equal, iff there exists a
cyclic permutation of the vertices of \f$ t2\f$, such that they are
equal to the vertices of `t`.
*/
bool operator==(const Triangle_2<Kernel> &t2) const;
/*!
Test for inequality.
*/
bool operator!=(const Triangle_2<Kernel> &t2) const;
/*!
returns the i'th vertex modulo 3 of `t`.
*/
Point_2<Kernel> vertex(int i) const;
/*!
returns `vertex(i)`.
*/
Point_2<Kernel> operator[](int i) const;
/// @}
/// \name Predicates
/// For convenience we provide the following Boolean functions:
/// @{
/*!
triangle `t` is degenerate, if the vertices are collinear.
*/
bool is_degenerate() const;
/*!
returns the orientation of `t`.
*/
Orientation orientation() const;
/*!
returns
`ON_ORIENTED_BOUNDARY`, or
`POSITIVE_SIDE`,
or the constant
`ON_NEGATIVE_SIDE`,
determined by the position of point \f$ p\f$.
\pre `t` is not degenerate.
*/
Oriented_side oriented_side(const Point_2<Kernel> &p) const;
/*!
returns the constant `ON_BOUNDARY`,
`ON_BOUNDED_SIDE`, or else
`ON_UNBOUNDED_SIDE`,
depending on where point \f$ p\f$ is.
\pre `t` is not degenerate.
*/
Bounded_side bounded_side(const Point_2<Kernel> &p) const;
/*!
*/
bool has_on_positive_side(const Point_2<Kernel> &p) const;
/*!
*/
bool has_on_negative_side(const Point_2<Kernel> &p) const;
/*!
*/
bool has_on_boundary(const Point_2<Kernel> &p) const;
/*!
*/
bool has_on_bounded_side(const Point_2<Kernel> &p) const;
/*!
\pre `t` is not degenerate.
*/
bool has_on_unbounded_side(const Point_2<Kernel> &p) const;
/// @}
/// \name Miscellaneous
/// @{
/*!
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).
*/
Triangle_2<Kernel> opposite();
/*!
returns the signed area of `t`.
*/
Kernel::FT area() const;
/*!
returns a bounding box containing `t`.
*/
Bbox_2 bbox() const;
/*!
returns the triangle obtained by applying \f$ at\f$ on the three
vertices of `t`.
*/
Triangle_2<Kernel> transform(const Aff_transformation_2<Kernel> &at) const;
/// @}
}; /* end Triangle_2 */
} /* end namespace CGAL */

View File

@ -0,0 +1,100 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object \f$ t\f$ of the class `Triangle_3` is a triangle in
the three-dimensional Euclidean space \f$ \E^3\f$. As the triangle is not
a full-dimensional object there is only a test whether a point lies on
the triangle or not.
\sa `Kernel::Triangle_3`
*/
template< typename Kernel >
class Triangle_3 {
public:
/// \name Creation
/// @{
/*!
introduces a triangle `t` with vertices \f$ p\f$, \f$ q\f$ and \f$ r\f$.
*/
Triangle_3(const Point_3<Kernel> &p,
const Point_3<Kernel> &q,
const Point_3<Kernel> &r);
/// @}
/// \name Operations
/// @{
/*!
Test for equality: two triangles t and \f$ t_2\f$ are equal, iff there
exists a cyclic permutation of the vertices of \f$ t2\f$, such that
they are equal to the vertices of `t`.
*/
bool operator==(const Triangle_3<Kernel> &t2) const;
/*!
Test for inequality.
*/
bool operator!=(const Triangle_3<Kernel> &t2) const;
/*!
returns the i'th vertex modulo 3 of `t`.
*/
Point_3<Kernel> vertex(int i) const;
/*!
returns `vertex(int i)`.
*/
Point_3<Kernel> operator[](int i) const;
/*!
returns the supporting plane of `t`, with same
orientation.
*/
Plane_3<Kernel> supporting_plane();
/// @}
/// \name Predicates
/// @{
/*!
`t` is degenerate if its vertices are collinear.
*/
bool is_degenerate() const;
/*!
A point is on `t`, if it is on a vertex, an edge or the
face of `t`.
*/
bool has_on(const Point_3<Kernel> &p) const;
/// @}
/// \name Miscellaneous
/// @{
/*!
returns a square of the area of `t`.
*/
Kernel::FT squared_area() const;
/*!
returns a bounding box containing `t`.
*/
Bbox_3 bbox() const;
/*!
returns the triangle obtained by applying \f$ at\f$ on the three
vertices of `t`.
*/
Triangle_3<Kernel> transform(const Aff_transformation_3<Kernel> &at) const;
/// @}
}; /* end Triangle_3 */

View File

@ -0,0 +1,263 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object of the class `Vector_2` is a vector in the two-dimensional
vector space \f$ \R^2\f$. Geometrically spoken, a vector is the difference
of two points \f$ p_2\f$, \f$ p_1\f$ and denotes the direction and the distance
from \f$ p_1\f$ to \f$ p_2\f$.
\cgal defines a symbolic constant `NULL_VECTOR`. We
will explicitly state where you can pass this constant as an argument
instead of a vector initialized with zeros.
\sa `Kernel::Vector_2`
*/
template< typename Kernel >
class Vector_2 {
public:
/// \name Types
/// @{
/*!
An iterator for enumerating the
Cartesian coordinates of a vector.
*/
typedef Hidden_type Cartesian_const_iterator;
/// @}
/// \name Creation
/// @{
/*!
introduces the vector \f$ b-a\f$.
*/
Vector_2(const Point_2<Kernel> &a, const Point_2<Kernel> &b);
/*!
introduces the vector \f$ s.target()-s.source()\f$.
*/
Vector_2(const Segment_2<Kernel> &s);
/*!
introduces the vector having the same direction as \f$ r\f$.
*/
Vector_2(const Ray_2<Kernel> &r);
/*!
introduces the vector having the same direction as \f$ l\f$.
*/
Vector_2(const Line_2<Kernel> &l);
/*!
introduces a null vector `v`.
*/
Vector_2(const Null_vector &NULL_VECTOR);
/*!
introduces a vector `v` initialized to \f$ (x,y)\f$.
*/
Vector_2(int x, int y);
/*!
introduces a vector `v` initialized to \f$ (x,y)\f$.
*/
Vector_2(double x, double y);
/*!
introduces a vector `v` initialized to \f$ (hx/hw,hy/hw)\f$.
\pre \f$ hw\neq0\f$.
*/
Vector_2(const Kernel::RT &hx, const Kernel::RT &hy, const Kernel::RT &hw = RT(1));
/*!
introduces a vector `v` initialized to \f$ (x,y)\f$.
*/
Vector_2(const Kernel::FT &x, const Kernel::FT &y);
/// @}
/// \name Operations
/// @{
/*!
Test for equality: two vectors are equal, iff their \f$ x\f$ and \f$ y\f$
coordinates are equal. You can compare a vector with the
`NULL_VECTOR`.
*/
bool operator==(const Vector_2<Kernel> &w) const;
/*!
Test for inequality. You can compare a vector with the
`NULL_VECTOR`.
*/
bool operator!=(const Vector_2<Kernel> &w) const;
/// @}
/// \name Coordinate Access
/// There are two sets of coordinate access functions, namely to the
/// homogeneous and to the Cartesian coordinates. They can be used
/// independently from the chosen kernel model. Note that you do not
/// loose information with the homogeneous representation, because the
/// `FieldNumberType` is a quotient.
/// @{
/*!
returns the homogeneous \f$ x\f$ coordinate.
*/
Kernel::RT hx() const;
/*!
returns the homogeneous \f$ y\f$ coordinate.
*/
Kernel::RT hy() const;
/*!
returns the homogenizing coordinate.
*/
Kernel::RT hw() const;
/*!
returns the `x`-coordinate of `v`, that is \f$ hx/hw\f$.
*/
Kernel::FT x() const;
/*!
returns the `y`-coordinate of `v`, that is \f$ hy/hw\f$.
*/
Kernel::FT y() const;
/// @}
/// \name Convenience Operators
/// The following operations are for convenience and for compatibility
/// with higher dimensional vectors. Again they come in a Cartesian
/// and homogeneous flavor.
/// @{
/*!
returns the i'th homogeneous coordinate of `v`, starting with 0.
\pre \f$ 0\leq i \leq2\f$.
*/
Kernel::RT homogeneous(int i) const;
/*!
returns the i'th Cartesian coordinate of `v`, starting at 0.
\pre \f$ 0\leq i \leq1\f$.
*/
Kernel::FT cartesian(int i) const;
/*!
returns `cartesian(i)`.
\pre \f$ 0\leq i \leq1\f$.
*/
Kernel::FT operator[](int i) const;
/*!
returns an iterator to the Cartesian coordinates
of `v`, starting with the 0th coordinate.
*/
Cartesian_const_iterator cartesian_begin() const;
/*!
returns an off the end iterator to the Cartesian
coordinates of `v`.
*/
Cartesian_const_iterator cartesian_end() const;
/*!
returns the dimension (the constant 2).
*/
int dimension() const;
/*!
returns the direction which passes through `v`.
*/
Direction_2<Kernel> direction() const;
/*!
returns the vector obtained by applying \f$ t\f$ on `v`.
*/
Vector_2<Kernel> transform(const Aff_transformation_2<Kernel> &t) const;
/*!
returns the vector perpendicular to `v` in clockwise or
counterclockwise orientation.
*/
Vector_2<Kernel> perpendicular(const Orientation &o) const;
/// @}
/// \name Operators
/// @{
/*!
Addition.
*/
Vector_2<Kernel> operator+(const Vector_2<Kernel> &w) const;
/*!
Subtraction.
*/
Vector_2<Kernel> operator-(const Vector_2<Kernel> &w) const;
/*!
returns the opposite vector.
*/
Vector_2<Kernel> operator-() const;
/*!
returns the scalar product (= inner product) of the two vectors.
*/
Kernel::FT operator*(const Vector_2<Kernel> &w) const;
/*!
Division by a scalar.
*/
Vector_2<Kernel> operator/(const Kernel::RT &s) const;
/*!
returns the squared length of `v`.
*/
Kernel::FT squared_length() const;
/// @}
}; /* end Vector_2 */
/*!
Multiplication with a scalar from the right.
\relates Vector_2
*/
Vector_2<Kernel>
operator*(const Vector_2<Kernel> &v, const Kernel::RT &s);
/*!
Multiplication with a scalar from the right.
\relates Vector_2
*/
Vector_2<Kernel>
operator*(const Vector_2<Kernel> &v, const Kernel::FT &s);
/*!
Multiplication with a scalar from the left.
\relates Vector_2
*/
Vector_2<Kernel>
operator*(const Kernel::RT &s, const Vector_2<Kernel> &v);
/*!
Multiplication with a scalar from the left.
\relates Vector_2
*/
Vector_2<Kernel>
operator*(const Kernel::FT &s, const Vector_2<Kernel> &v);
} /* end namespace CGAL */

View File

@ -0,0 +1,266 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
An object of the class `Vector_3` is a vector in the three-dimensional
vector space \f$ \R^3\f$. Geometrically spoken a vector is the difference
of two points \f$ p_2\f$, \f$ p_1\f$ and denotes the direction and the distance
from \f$ p_1\f$ to \f$ p_2\f$.
\cgal defines a symbolic constant `NULL_VECTOR`. We
will explicitly state where you can pass this constant as an argument
instead of a vector initialized with zeros.
\sa `Kernel::Vector_3`
\sa `CGAL::cross_product`
\sa `CGAL::determinant`
*/
template< typename Kernel >
class Vector_3 {
public:
/// \name Types
/// @{
/*!
An iterator for enumerating the
Cartesian coordinates of a vector.
*/
typedef Hidden_type Cartesian_const_iterator;
/// @}
/// \name Creation
/// @{
/*!
introduces the vector \f$ b-a\f$.
*/
Vector_3(const Point_3<Kernel> &a, const Point_3<Kernel> &b);
/*!
introduces the vector \f$ s.target()-s.source()\f$.
*/
Vector_3(const Segment_3<Kernel> &s);
/*!
introduces a vector having the same direction as \f$ r\f$.
*/
Vector_3(const Ray_3<Kernel> &r);
/*!
introduces a vector having the same direction as \f$ l\f$.
*/
Vector_3(const Line_3<Kernel> &l);
/*!
introduces a null vector `v`.
*/
Vector_3(const Null_vector &NULL_VECTOR);
/*!
introduces a vector `v` initialized to \f$ (x, y, z)\f$.
*/
Vector_3(int x, int y, int z);
/*!
introduces a vector `v` initialized to \f$ (x, y, z)\f$.
*/
Vector_3(double x, double y, double z);
/*!
introduces a vector `v` initialized to \f$ (hx/hw, hy/hw, hz/hw)\f$.
*/
Vector_3(const Kernel::RT &hx, const Kernel::RT &hy, const Kernel::RT &hz, const Kernel::RT &hw = RT(1));
/*!
introduces a vector `v` initialized to \f$ (x, y, z)\f$.
*/
Vector_3(const Kernel::FT &x, const Kernel::FT &y, const Kernel::FT &z);
/// @}
/// \name Operations
/// @{
/*!
Test for equality: two vectors are equal, iff their \f$ x\f$, \f$ y\f$
and \f$ z\f$ coordinates are equal. You can compare a vector with the
`NULL_VECTOR`.
*/
bool operator==(const Vector_3<Kernel> &w) const;
/*!
Test for inequality. You can compare a vector with the
`NULL_VECTOR`.
*/
bool operator!=(const Vector_3<Kernel> &w) const;
/// @}
/// \name Coordinate Access
/// There are two sets of coordinate access functions, namely to the
/// homogeneous and to the Cartesian coordinates. They can be used
/// independently from the chosen kernel model. Note that you do not
/// loose information with the homogeneous representation, because the
/// `FieldNumberType` is a quotient.
/// @{
/*!
returns the homogeneous \f$ x\f$ coordinate.
*/
Kernel::RT hx() const;
/*!
returns the homogeneous \f$ y\f$ coordinate.
*/
Kernel::RT hy() const;
/*!
returns the homogeneous \f$ z\f$ coordinate.
*/
Kernel::RT hz() const;
/*!
returns the homogenizing coordinate.
*/
Kernel::RT hw() const;
/*!
returns the `x`-coordinate of `v`, that is \f$ hx/hw\f$.
*/
Kernel::FT x() const;
/*!
returns the `y`-coordinate of `v`, that is \f$ hy/hw\f$.
*/
Kernel::FT y() const;
/*!
returns the `z` coordinate of `v`, that is \f$ hz/hw\f$.
*/
Kernel::FT z() const;
/// @}
/// \name Convenience Operations
/// The following operations are for convenience and for compatibility
/// with higher dimensional vectors. Again they come in a Cartesian
/// and homogeneous flavor.
/// @{
/*!
returns the i'th homogeneous coordinate of `v`, starting with 0.
\pre \f$ 0\leq i \leq3\f$.
*/
Kernel::RT homogeneous(int i) const;
/*!
returns the i'th Cartesian coordinate of `v`, starting at 0.
\pre \f$ 0\leq i \leq2\f$.
*/
Kernel::FT cartesian(int i) const;
/*!
returns `cartesian(i)`.
\pre \f$ 0\leq i \leq2\f$.
*/
Kernel::FT operator[](int i) const;
/*!
returns an iterator to the Cartesian coordinates
of `v`, starting with the 0th coordinate.
*/
Cartesian_const_iterator cartesian_begin() const;
/*!
returns an off the end iterator to the Cartesian
coordinates of `v`.
*/
Cartesian_const_iterator cartesian_end() const;
/*!
returns the dimension (the constant 3).
*/
int dimension() const;
/*!
returns the vector obtained by applying \f$ t\f$ on `v`.
*/
Vector_3<Kernel> transform(const Aff_transformation_3<Kernel> &t) const;
/*!
returns the direction of `v`.
*/
Direction_3<Kernel> direction() const;
/// @}
/// \name Operators
/// @{
/*!
Addition.
*/
Vector_3<Kernel> operator+(const Vector_3<Kernel> &w) const;
/*!
Subtraction.
*/
Vector_3<Kernel> operator-(const Vector_3<Kernel> &w) const;
/*!
Returns the opposite vector.
*/
Vector_3<Kernel> operator-() const;
/*!
Division by a scalar.
*/
Vector_3<Kernel> operator/(const Kernel::RT &s) const;
/*!
returns the squared length of `v`.
*/
Kernel::FT squared_length() const;
/// @}
}; /* end Vector_3 */
/*!
returns the scalar product (= inner product) of the two vectors.
*/
Kernel::FT operator*(const Vector_3<Kernel> &w) const;
/*!
Multiplication with a scalar from the right.
\relates Vector_3
*/
Vector_3<Kernel>
operator*(const Vector_3<Kernel> &v, const Kernel::RT &s);
/*!
Multiplication with a scalar from the right.
\relates Vector_3
*/
Vector_3<Kernel>
operator*(const Vector_3<Kernel> &v, const Kernel::FT &s);
/*!
Multiplication with a scalar from the left.
\relates Vector_3
*/
Vector_3<Kernel>
operator*(const Kernel::RT &s, const Vector_3<Kernel> &v);
/*!
Multiplication with a scalar from the left.
\relates Vector_3
*/
Vector_3<Kernel>
operator*(const Kernel::FT &s, const Vector_3<Kernel> &v);
} /* end namespace CGAL */

View File

@ -0,0 +1,120 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
Tag class for affine transformations.
\sa `CGAL::Aff_transformation_2<Kernel>`
\sa `CGAL::Aff_transformation_3<Kernel>`
\sa `CGAL::Reflection`
\sa `CGAL::Rotation`
\sa `CGAL::Scaling`
\sa `CGAL::Translation`
*/
class Identity_transformation {
public:
/// @}
}; /* end Identity_transformation */
} /* end namespace CGAL */
namespace CGAL {
/*!
\ingroup PkgKernel23
Tag class for affine transformations.
\sa `CGAL::Aff_transformation_2<Kernel>`
\sa `CGAL::Aff_transformation_3<Kernel>`
\sa `CGAL::Identity_transformation`
\sa `CGAL::Rotation`
\sa `CGAL::Scaling`
\sa `CGAL::Translation`
*/
class Reflection {
public:
/// @}
}; /* end Reflection */
} /* end namespace CGAL */
namespace CGAL {
/*!
\ingroup PkgKernel23
Tag class for affine transformations.
\sa `CGAL::Aff_transformation_2<Kernel>`
\sa `CGAL::Aff_transformation_3<Kernel>`
\sa `CGAL::Identity_transformation`
\sa `CGAL::Rotation`
\sa `CGAL::Scaling`
\sa `CGAL::Translation`
*/
class Rotation {
public:
/// @}
}; /* end Rotation */
} /* end namespace CGAL */
namespace CGAL {
/*!
\ingroup PkgKernel23
Tag class for affine transformations.
\sa `CGAL::Aff_transformation_2<Kernel>`
\sa `CGAL::Aff_transformation_3<Kernel>`
\sa `CGAL::Identity_transformation`
\sa `CGAL::Reflection`
\sa `CGAL::Rotation`
\sa `CGAL::Translation`
*/
class Scaling {
public:
/// @}
}; /* end Scaling */
} /* end namespace CGAL */
namespace CGAL {
/*!
\ingroup PkgKernel23
Tag class for affine transformations.
\sa `CGAL::Aff_transformation_2<Kernel>`
\sa `CGAL::Aff_transformation_3<Kernel>`
\sa `CGAL::Identity_transformation`
\sa `CGAL::Reflection`
\sa `CGAL::Rotation`
\sa `CGAL::Scaling`
*/
class Translation {
public:
/// @}
}; /* end Translation */
} /* end namespace CGAL */

View File

@ -0,0 +1,100 @@
namespace CGAL {
/*!
\addtogroup kernel_conversion Cartesian/Homogenous Conversion
\ingroup PkgKernel23
Functions to convert between Cartesian and Homogeneous Kernels.
\sa `CGAL::Cartesian<FieldNumberType>`
\sa `CGAL::Cartesian_converter<K1, K2, NTConverter>`
\sa `CGAL::Homogeneous<RingNumberType>`
\sa `CGAL::Homogeneous_converter<K1, K2, RTConverter, FTConverter>`
\sa `CGAL::Simple_cartesian<FieldNumberType>`
\sa `CGAL::Simple_homogeneous<RingNumberType>`
*/
/// @{
/*!
converts 2d point `cp` with Cartesian representation
into a 2d point with homogeneous representation with the same
number type.
*/
Point_2< Homogeneous<RT> >
cartesian_to_homogeneous(const Point_2< Cartesian<RT> >& cp);
/*!
converts 3d point `cp` with Cartesian representation
into a 3d point with homogeneous representation with the same
number type.
*/
Point_3< Homogeneous<RT> >
cartesian_to_homogeneous(const Point_3< Cartesian<RT> >& cp);
/*!
converts 2d point `hp` with homogeneous representation
into a 2d point with Cartesian representation with the same
number type.
*/
Point_2< Cartesian<FT> >
homogeneous_to_cartesian(const Point_2< Homogeneous<FT> >& hp);
/*!
converts 3d point `hp` with homogeneous representation
into a 3d point with Cartesian representation with the same
number type.
*/
Point_3< Cartesian<FT> >
homogeneous_to_cartesian(const Point_3< Homogeneous<FT> >& hp);
/*!
converts the 2d point `hp` with homogeneous representation
with number type `RT` into a 2d point with Cartesian
representation with number type `Quotient<RT>`.
*/
Point_2< Cartesian<Quotient<RT> > >
homogeneous_to_quotient_cartesian(const Point_2<Homogeneous<RT> >& hp);
/*!
converts the 3d point `hp` with homogeneous representation
with number type `RT` into a 3d point with Cartesian
representation with number type `Quotient<RT>`.
*/
Point_3< Cartesian<Quotient<RT> > >
homogeneous_to_quotient_cartesian(const Point_3<Homogeneous<RT> >& hp);
/*!
converts 2d point `cp` with Cartesian representation
with number type `Quotient<RT>` into a 2d point
with homogeneous representation with number type `RT`.
*/
Point_2< Homogeneous<RT> >
quotient_cartesian_to_homogeneous(
const Point_2< Cartesian< Quotient<RT> > >& cp);
/*!
converts 3d point `cp` with Cartesian representation
with number type `Quotient<RT>` into a 3d point
with homogeneous representation with number type `RT`.
*/
Point_3< Homogeneous<RT> >
quotient_cartesian_to_homogeneous(
const Point_3< Cartesian< Quotient<RT> > >& cp);
} /* namespace CGAL */

View File

@ -0,0 +1,159 @@
namespace CGAL {
/*!
\ingroup PkgKernel23
converts between the various enums provided by the \cgal kernel.
The conversion preserves the order of the values.
\sa `CGAL::Sign`
\sa `CGAL::Comparison_result`
\sa `CGAL::Orientation`
\sa `CGAL::Oriented_side`
\sa `CGAL::Bounded_side`
\sa `CGAL::Angle`
\sa `CGAL::Uncertain<T>`
*/
template < typename T, typename U >
T enum_cast(const U&u);
/*!
\ingroup PkgKernel23
returns the opposite side (for example `ON_POSITIVE_SIDE` if
`o==ON_NEGATIVE_SIDE`), or `ON_ORIENTED_BOUNDARY` if
`o==ON_ORIENTED_BOUNDARY`.
*/
Oriented_side opposite(const Oriented_side &o);
/*!
\ingroup PkgKernel23
returns the opposite side (for example `BOUNDED_SIDE` if
`o==UNBOUNDED_SIDE`), or returns `ON_BOUNDARY` if
`o==ON_BOUNDARY`.
*/
Bounded_side opposite(const Bounded_side &o);
/*!
\ingroup PkgKernel23
\sa `CGAL::angle`
*/
enum Angle {OBTUSE, RIGHT, ACUTE};
/*!
\ingroup PkgKernel23
\sa `CGAL::opposite(const Bounded_side& o)`
*/
enum Bounded_side {ON_UNBOUNDED_SIDE, ON_BOUNDARY, ON_BOUNDED_SIDE};
/*!
\ingroup PkgKernel23
*/
enum Comparison_result { SMALLER, EQUAL, LARGER };
/*!
\ingroup PkgKernel23
\sa CGAL::Orientation
*/
enum Sign { NEGATIVE, ZERO, POSITIVE };
/*!
\ingroup PkgKernel23
\sa `CGAL::LEFT_TURN`
\sa `CGAL::RIGHT_TURN`
\sa `CGAL::COLLINEAR`
\sa `CGAL::CLOCKWISE`
\sa `CGAL::COUNTERCLOCKWISE`
\sa `CGAL::COPLANAR`
*/
typedef Sign Orientation;
/*!
\ingroup PkgKernel23
*/
enum Oriented_side {ON_NEGATIVE_SIDE, ON_ORIENTED_BOUNDARY, ON_POSITIVE_SIDE };
/*!
\ingroup PkgKernel23
\sa `CGAL::COUNTERCLOCKWISE`
*/
const Orientation CLOCKWISE = NEGATIVE;
/*!
\ingroup PkgKernel23
\sa `CGAL::CLOCKWISE`
*/
const Orientation COUNTERCLOCKWISE = POSITIVE;
/*!
\ingroup PkgKernel23
\sa `CGAL::LEFT_TURN`
\sa `CGAL::RIGHT_TURN`
*/
const Orientation COLLINEAR = ZERO;
/*!
\ingroup PkgKernel23
\sa `CGAL::COLLINEAR`
\sa `CGAL::RIGHT_TURN`
*/
const Orientation LEFT_TURN = POSITIVE;
/*!
\ingroup PkgKernel23
\sa `CGAL::COLLINEAR`
\sa `CGAL::LEFT_TURN`
*/
const Orientation RIGHT_TURN = NEGATIVE;
/*!
\ingroup PkgKernel23
*/
const Orientation COPLANAR = ZERO;
/*!
\ingroup PkgKernel23
*/
const Orientation DEGENERATE = ZERO;
/*!
\ingroup PkgKernel23
A symbolic constant used to construct zero length vectors.
\sa `CGAL::Vector_2<Kernel>`
\sa `CGAL::Vector_3<Kernel>`
*/
const Null_vector NULL_VECTOR;
/*!
\ingroup PkgKernel23
A symbolic constant which denotes the point at the origin.
This constant is used in the conversion between points and vectors.
Example
--------------
\code
Point_2< Cartesian<Exact_NT> > p(1.0, 1.0), q;
Vector2< Cartesian<Exact_NT> > v;
v = p - ORIGIN;
q = ORIGIN + v;
assert( p == q );
\endcode
\sa `CGAL::Point_2<Kernel>`
\sa `CGAL::Point_3<Kernel>`
*/
const Origin ORIGIN;
} /* namespace CGAL */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,611 @@
namespace CGAL {
/*!
\addtogroup do_intersect do_intersect
\ingroup PkgKernel23
Depending on which \cgal kernel is used, different versions of this
global function are available.
## With the basic 2D and 3D Kernel ##
See Chapter \ref chapterkernel23
\code
#include <CGAL/intersections.h>
\endcode
The types `Type1` and `Type2` can be any of the following:
- `Point_2<Kernel>`
- `Line_2<Kernel>`
- `Ray_2<Kernel>`
- `Segment_2<Kernel>`
- `Triangle_2<Kernel>`
- `Iso_rectangle_2<Kernel>`
Also, `Type1` and `Type2` can be both of type
- `Line_2<Kernel>`
- `Circle_2<Kernel>`
In three-dimensional space, the types `Type1` and
`Type2` can be any of the following:
- `Plane_3<Kernel>`
- `Line_3<Kernel>`
- `Ray_3<Kernel>`
- `Segment_3<Kernel>`
- `Triangle_3<Kernel>`.
- `Bbox_3`.
Also, `Type1` and `Type2` can be respectively of types
- `Triangle_3<Kernel>` and `Tetrahedron_3<Kernel>`
- `Plane_3<Kernel>` and `Sphere_3<Kernel>` (or the contrary)
- `Sphere_3<Kernel>` and `Sphere_3<Kernel>`.
## With the 2D Circular Kernel ##
See Chapter \ref chaptercircularkernel
\code
#include <CGAL/Circular_kernel_intersections.h>
\endcode
If this kernel is used, in addition to the combinations of 2D types
previously listed, `Type1` and `Type2` can be any of
the following:
- `Line_2<CircularKernel>`
- `Circle_2<CircularKernel>`
- `Line_arc_2<CircularKernel>`
- `Circular_arc_2<CircularKernel>`
An example illustrating this is presented in
Chapter \ref chaptercircularkernel.
## With the 3D Spherical Kernel ##
See Chapter \ref chaptersphericalkernel
\code
#include <CGAL/Spherical_kernel_intersections.h>
\endcode
If this kernel is used, in addition to the combinations of 3D types
previously listed, `Type1` and `Type2` can be any of
the following:
- `Line_3<SphericalKernel>`
- `Circle_3<SphericalKernel>`
- `Plane_3<SphericalKernel>`
- `Sphere_3<SphericalKernel>`
- `Line_arc_3<SphericalKernel>`
- `Circular_arc_3<SphericalKernel>`
An example illustrating this is presented in
Chapter \ref chaptersphericalkernel.
\sa `CGAL::intersection`
*/
/// @{
/*!
checks whether `obj1` and `obj2` intersect. Two objects `obj1` and
`obj2` intersect if there is a point `p` that is part of both `obj1`
and `obj2`. The intersection region of those two objects is defined
as the set of all points `p` that are part of both `obj1` and `obj2`.
Note that for objects like triangles and polygons that enclose a
bounded region, this region is part of the object.
*/
bool do_intersect(Type1 obj1, Type2 obj2);
/*!
\ingroup PkgKernel23
checks whether `obj1`, `obj2` and `obj3` intersect.
`Type1`, `Type2` and `Type3` can be:
- `Sphere_3<SphericalKernel>`
- `Plane_3<SphericalKernel>`
\attention Only available with a SphericalKernel.
*/
bool do_intersect(Type1 obj1, Type2 obj2, Type3 obj3);
/// @}
/*!
\addtogroup intersection intersection
\ingroup PkgKernel23
Depending on which \cgal kernel is used, different versions of this
global function are available.
Example
--------------
The following example demonstrates the most common use of
`intersection` routines with the basic 2D and 3D Kernels.
\code
#include <CGAL/intersections.h>
void foo(CGAL::Segment_2<Kernel> seg, CGAL::Line_2<Kernel> line)
{
CGAL::Object result = CGAL::intersection(seg, line);
if (const CGAL::Point_2<Kernel> *ipoint = CGAL::object_cast<CGAL::Point_2<Kernel> >(&result)) {
// handle the point intersection case with *ipoint.
} else
if (const CGAL::Segment_2<Kernel> *iseg = CGAL::object_cast<CGAL::Segment_2<Kernel> >(&result)) {
// handle the segment intersection case with *iseg.
} else {
// handle the no intersection case.
}
}
\endcode
Examples illustrating the use of this function in the case of the 2D
Circular %Kernel and the 3D Spherical %Kernel are presented respectively
in Chapters \ref chaptercircularkernel and \ref
chaptersphericalkernel.
\sa `CGAL::do_intersect`
\sa `CGAL::Object`
## With the basic 2D and 3D Kernel ##
See Chapter \ref chapterkernel23
*/
/// @{
/*!
Two objects `obj1` and `obj2` intersect if there is a point `p` that
is part of both `obj1` and `obj2`. The intersection region of those
two objects is defined as the set of all points `p` that are part of
both `obj1` and `obj2`. Note that for objects like triangles and
polygons that enclose a bounded region, this region is considered part
of the object. If a segment lies completely inside a triangle, then
those two objects intersect and the intersection region is the
complete segment.
The possible value for types `Type1` and `Type2` and the
possible return values wrapped in `Object` are the
following:
<DIV ALIGN="CENTER">
<TABLE CELLPADDING=3 BORDER="1">
<TR> <TH> type A </TH>
<TH> type B </TH>
<TH> return type </TH>
</TR>
<TR>
<TD VALIGN="CENTER" > Iso_rectangle_2 </TD>
<TD VALIGN="CENTER" > Iso_rectangle_2 </TD>
<TD><TABLE>
<TR><TD>Iso_rectangle_2</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Iso_rectangle_2 </TD>
<TD VALIGN="CENTER" > Line_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Segment_2</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Iso_rectangle_2 </TD>
<TD VALIGN="CENTER" > Ray_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Segment_2</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Iso_rectangle_2 </TD>
<TD VALIGN="CENTER" > Segment_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Segment_2</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Iso_rectangle_2 </TD>
<TD VALIGN="CENTER" > Triangle_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Segment_2</TD></TR>
<TR><TD>Triangle_2</TD></TR>
<TR><TD>std::vector&lt;Point_2&gt;</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Line_2 </TD>
<TD VALIGN="CENTER" > Line_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Line_2</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Line_2 </TD>
<TD VALIGN="CENTER" > Ray_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Ray_2</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Line_2 </TD>
<TD VALIGN="CENTER" > Segment_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Segment_2</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Line_2 </TD>
<TD VALIGN="CENTER" > Triangle_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Segment_2</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Ray_2 </TD>
<TD VALIGN="CENTER" > Ray_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Segment_2</TD></TR>
<TR><TD>Ray_2</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Ray_2 </TD>
<TD VALIGN="CENTER" > Segment_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Segment_2</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Ray_2 </TD>
<TD VALIGN="CENTER" > Triangle_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Segment_2</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Segment_2 </TD>
<TD VALIGN="CENTER" > Segment_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Segment_2</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Segment_2 </TD>
<TD VALIGN="CENTER" > Triangle_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Segment_2</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Triangle_2 </TD>
<TD VALIGN="CENTER" > Triangle_2 </TD>
<TD><TABLE>
<TR><TD>Point_2</TD></TR>
<TR><TD>Segment_2</TD></TR>
<TR><TD>Triangle_2</TD></TR>
<TR><TD>std::vector&lt;Point_2&gt;</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Line_3 </TD>
<TD VALIGN="CENTER" > Line_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Line_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Line_3 </TD>
<TD VALIGN="CENTER" > Plane_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Line_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Line_3 </TD>
<TD VALIGN="CENTER" > Ray_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Ray_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Line_3 </TD>
<TD VALIGN="CENTER" > Segment_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Segment_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Line_3 </TD>
<TD VALIGN="CENTER" > Triangle_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Segment_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Plane_3 </TD>
<TD VALIGN="CENTER" > Plane_3 </TD>
<TD><TABLE>
<TR><TD>Line_3</TD></TR>
<TR><TD>Plane_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Plane_3 </TD>
<TD VALIGN="CENTER" > Ray_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Ray_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Plane_3 </TD>
<TD VALIGN="CENTER" > Segment_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Segment_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Plane_3 </TD>
<TD VALIGN="CENTER" > Sphere_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Circle_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Plane_3 </TD>
<TD VALIGN="CENTER" > Triangle_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Segment_3</TD></TR>
<TR><TD>Triangle_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Ray_3 </TD>
<TD VALIGN="CENTER" > Ray_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Ray_3</TD></TR>
<TR><TD>Segment_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Ray_3 </TD>
<TD VALIGN="CENTER" > Segment_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Segment_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Ray_3 </TD>
<TD VALIGN="CENTER" > Triangle_3 </TD>
p <TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Segment_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Segment_3 </TD>
<TD VALIGN="CENTER" > Segment_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Segment_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Segment_3 </TD>
<TD VALIGN="CENTER" > Triangle_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Segment_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Sphere_3 </TD>
<TD VALIGN="CENTER" > Sphere_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Circle_3</TD></TR>
<TR><TD>Sphere_3</TD></TR>
</TABLE></TD>
</TR>
<TR>
<TD VALIGN="CENTER" > Triangle_3 </TD>
<TD VALIGN="CENTER" > Triangle_3 </TD>
<TD><TABLE>
<TR><TD>Point_3</TD></TR>
<TR><TD>Segment_3</TD></TR>
<TR><TD>Triangle_3</TD></TR>
<TR><TD>std::vector &lt; Point_3 &gt; </TD></TR>
</TABLE></TD>
</TR>
</TABLE>
</DIV>
*/
Object intersection(Type1<Kernel> obj1, Type2<Kernel> obj2);
/*!
returns the intersection of 3 planes, which can be either a
point, a line, a plane, or empty.
*/
Object intersection(const Plane_3<Kernel>& pl1,
const Plane_3<Kernel>& pl2,
const Plane_3<Kernel>& pl3);
/*!
\name With the 2D Circular Kernel
See Chapter \ref chaptercircularkernel
\code
#include <CGAL/Circular_kernel_intersections.h>
\endcode
If this kernel is used, in addition to the function and the
combination of 2D types described above, another version of the function
is provided.
Since both the number of intersections, if any, and their type,
depend on the arguments, the function returns an output
iterator on `Object`'s, as presented below.
*/
/// @{
/*!
Copies in the output iterator the intersection elements between the
two objects. `intersections` iterates on
elements of type `CGAL::Object`, in lexicographic order,
where `Type1` and `Type2` can both be either
- `Line_2<CircularKernel>` or
- `Line_arc_2<CircularKernel>` or
- `Circle_2<CircularKernel>` or
- `Circular_arc_2<CircularKernel>`
Depending on the types `Type1` and `Type2`, these elements can be assigned to
- `std::pair<Circular_arc_point_2<CircularKernel>, unsigned>`,
where the unsigned integer is the multiplicity of the corresponding
intersection point between `obj1` and `obj2`,
- `Circular_arc_2<CircularKernel>` in case of an overlap of
two circular arcs,
- `Line_arc_2<CircularKernel>` in case of an overlap of two
line segments or
- `Line_2<CircularKernel>` or
`Circle_2<CircularKernel>` in case of two equal input lines or circles.
*/
template < class OutputIterator >
OutputIterator
intersection(const Type1 &obj1, const Type2 &obj2,
OutputIterator intersections);
/// @}
/*!
\name With the 3D Circular Kernel
See Chapter \ref chaptersphericalkernel
\code
#include <CGAL/Spherical_kernel_intersections.h>
\endcode
If this kernel is used, in addition to the function and the
combination of 3D types described above, two other versions of the function
are provided.
Since both the number of intersections, if any, and their type,
depend on the arguments, the functions return an output
iterator on `Object`'s, as presented below.
*/
/// @{
/*!
Copies in the output iterator the intersection elements between the
two objects. `intersections` iterates on
elements of type `CGAL::Object`, in lexicographic order,
when this ordering is defined on the computed objects,
where `SphericalType1` and `SphericalType2` can both be either:
- `Sphere_3<SphericalKernel>`,
- `Plane_3<SphericalKernel>`,
- `Line_3<SphericalKernel>`,
- `Circle_3<SphericalKernel>`,
- `Line_arc_3<SphericalKernel>` or
- `Circular_arc_3<SphericalKernel>`,
and depending on the types `SphericalType1` and `SphericalType2`, the computed
`CGAL::Object`s can be assigned to
- `std::pair<Circular_arc_point_3<SphericalKernel>, unsigned>`,
where the unsigned integer is the multiplicity of the corresponding
intersection point between `obj1` and `obj2`,
- `SphericalType1`, when `SphericalType1` and `SphericalType2` are equal,
and if the two objets `obj1` and `obj2` are equal,
- `Line_3<SphericalKernel>` or
`Circle_3<SphericalKernel>` when `SphericalType1` and `SphericalType2`
are two-dimensional objets intersecting along a curve (2 planes, or 2
spheres, or one plane and one sphere),
- `Circular_arc_3<SphericalKernel>` in case of an overlap of
two circular arcs or
- `Line_arc_3<SphericalKernel>` in case of an overlap of two
line segments.
*/
template < class OutputIterator >
OutputIterator
intersection(const SphericalType1 &obj1, const SphericalType2 &obj2,
OutputIterator intersections);
/*!
Copies in the output iterator the intersection elements between the
three objects. `intersections` iterates on
elements of type `CGAL::Object`, in lexicographic order
when this ordering is defined on the computed objects
where `Type1`, `Type2` and `Type3`
can be either
- `Sphere_3<SphericalKernel>` or
- `Plane_3<SphericalKernel>`
and depending of these types, the computed `CGAL::Object`s can be
assigned to
- `std::pair<Circular_arc_point_3<SphericalKernel>, unsigned>`,
where the unsigned integer is the multiplicity of the corresponding
intersection point,
- `Circle_3<SphericalKernel>` or
- `Type1`, when `Type1`, `Type2` and
`Type3` are equal, and if the three objets `obj1` and `obj2`
and `obj3` are equal.
*/
template < class OutputIterator >
OutputIterator
intersection(const Type1 &obj1, const Type2 &obj2, const Type3 &obj3,
OutputIterator intersections);
/// @}
}

View File

@ -0,0 +1,38 @@
namespace CGAL {
/*!
\addtogroup rational_rotation_approximation rational_rotation_approximation
\ingroup PkgKernel23
*/
/*!
\ingroup rational_rotation_approximation
computes integers `sin_num`, `cos_num` and `denom`, such
that `sin_num`/`denom` approximates the sine of direction
\f$ (\f$`dirx`,`diry`\f$ )\f$. The difference between the sine and
the approximating rational is bounded by `eps_num`/`eps_den`.
\pre `eps_num` \f$ \neq0\f$.
Implementation
--------------
The approximation is based on Farey sequences as described in
the rational rotation method presented by Canny and Ressler at the
8th SoCG 1992. We use a slower version which needs no division operation
in the approximation.
\sa `CGAL::Aff_transformation_2<Kernel>`
*/
template <RingNumberType>
void
rational_rotation_approximation( const RingNumberType & dirx,
const RingNumberType & diry,
RingNumberType & sin_num,
RingNumberType & cos_num,
RingNumberType & denom,
const RingNumberType & eps_num,
const RingNumberType & eps_den );
} /* namespace CGAL */

View File

@ -0,0 +1,50 @@
namespace CGAL {
/*!
\addtogroup squared_distance squared_distance
\ingroup PkgKernel23
*/
/// @{
/*!
computes the square of the Euclidean distance between two geometric
objects. For arbitrary geometric objects `obj1` and `obj2` the
squared distance is defined as the minimal `squared_distance(p1, p2)`,
where `p1` is a point of `obj1` and `p2` is a point of `obj2`. Note
that for objects that have an inside (a bounded region), this inside
is part of the object. So, the squared distance from a point inside is
zero, not the squared distance to the closest point on the boundary.
In 2D, the types `Type1` and `Type2` can be any of the following:
- `Point_2`
- `Line_2`
- `Ray_2`
- `Segment_2`
- `Triangle_2`
In 3D, the types `Type1` and `Type2` can be any of the
following:
- `Point_3`
- `Line_3`
- `Ray_3`
- `Segment_3`
- `Plane_3`
\note For the 3D functionality \ref squared_distance_3.h has to be included.
\sa `CGAL::compare_distance_to_point`
\sa `CGAL::compare_signed_distance_to_line`
\sa `CGAL::compare_signed_distance_to_plane`
\sa `CGAL::has_larger_distance_to_point`
\sa `CGAL::has_larger_signed_distance_to_line`
\sa `CGAL::has_larger_signed_distance_to_plane`
\sa `CGAL::has_smaller_distance_to_point`
\sa `CGAL::has_smaller_signed_distance_to_line`
\sa `CGAL::has_smaller_signed_distance_to_plane`
*/
Kernel::FT squared_distance(Type1<Kernel> obj1, Type2<Kernel> obj2);
/// @}
}

View File

@ -0,0 +1,3 @@
/*!
\file squared_distance_3.h
*/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,727 @@
namespace CGAL {
/*!
\mainpage 2D and 3D Geometry Kernel
\anchor chapterkernel23
\authors Herv&eacute; Br&ouml;nnimann, Andreas Fabri, Geert-Jan Giezeman, Susan Hert, Michael Hoffmann, Lutz Kettner, Sylvain Pion, and Stefan Schirra
# Introduction #
\cgal, the <I>Computational Geometry Algorithms Library</I>, is written in
\cpp and consists of three major parts.
The first part is the kernel, which consists of constant-size non-modifiable
geometric primitive objects and operations on these objects.
The objects are represented both as stand-alone classes that are
parameterized by a representation class, which specifies
the underlying number types used for calculations and as members of the
kernel classes, which allows for more flexibility and adaptability of the
kernel.
The second part is a collection of basic geometric data structures and
algorithms, which are parameterized by traits classes that define the
interface between the data structure or algorithm and the primitives they use.
In many cases, the kernel classes provided in \cgal can be used as traits
classes for these data structures and algorithms.
The third part of the library consists of non-geometric support facilities,
such as circulators, random sources, I/O support for debugging and for
interfacing \cgal to various visualization tools.
This part of the reference manual covers the kernel.
The kernel contains objects of constant size, such as point, vector,
direction, line, ray, segment, triangle, iso-oriented rectangle and
tetrahedron.
With each type comes a set of functions which can be applied to an object
of this type.
You will typically find access functions (e.g. to the coordinates of a point),
tests of the position of a point relative to the object, a function returning
the bounding box, the length, or the area of an object, and so on.
The \cgal kernel further contains basic operations such as affine
transformations, detection and computation of intersections, and distance
computations.
## Robustness ##
The correctness proof of nearly all geometric algorithms presented
in theory papers assumes exact computation with real numbers.
This leads to a fundamental problem with the implementation of geometric
algorithms.
Naively, often the exact real arithmetic is replaced by inexact floating-point
arithmetic in the implementation.
This often leads to acceptable results for many input data.
However, even for the implementation of the simplest geometric
algorithms this simplification occasionally does not work.
Rounding errors introduced by an inaccurate arithmetic may lead to
inconsistent decisions, causing unexpected failures for some correct
input data.
There are many approaches to this problem, one of them is to compute
exactly (compute so accurate that all decisions made by the algorithm
are exact) which is possible in many cases but more expensive
than standard floating-point arithmetic.
C. M. Hoffmann \cite h-gsm-89, \cite h-pargc-89 illustrates some
of the problems arising in the implementation of geometric algorithms
and discusses some approaches to solve them.
A more recent overview is given in \cite s-rpigc-00.
The exact computation paradigm is discussed by Yap and Dub&eacute;
\cite yd-ecp-95 and Yap \cite y-tegc-97.
In \cgal you can choose the underlying number types and arithmetic.
You can use different types of arithmetic simultaneously and the choice can
be easily changed, e.g. for testing.
So you can choose between implementations with fast but occasionally inexact
arithmetic and implementations guaranteeing exact computation and exact
results.
Of course you have to pay for the exactness in terms of execution time
and storage space.
See the dedicated chapter
for more details on number types and their capabilities and performance.
# Kernel Representations #
Our object of study is the \f$ d\f$-dimensional affine Euclidean space.
Here we are mainly concerned with cases \f$ d=2\f$ and \f$ d=3\f$.
Objects in that space are sets of points. A common way to represent
the points is the use of Cartesian coordinates,
which assumes a reference frame (an origin and \f$ d\f$ orthogonal axes).
In that framework, a point is represented by a \f$ d\f$-tuple
\f$ (c_0,c_1,\ldots,c_{d-1})\f$,
and so are vectors in the underlying linear space. Each point is
represented uniquely by such Cartesian coordinates.
Another way to represent points is by homogeneous coordinates. In that
framework, a point is represented by a \f$ (d+1)\f$-tuple
\f$ (h_0,h_1,\ldots,h_d)\f$.
Via the formulae \f$ c_i = h_i/h_d\f$,
the corresponding point with Cartesian coordinates
\f$ (c_0,c_1,\ldots,c_{d-1})\f$
can be computed. Note that homogeneous coordinates are not unique.
For \f$ \lambda\ne 0\f$, the tuples \f$ (h_0,h_1,\ldots,h_d)\f$ and
\f$ (\lambda\cdot h_0,\lambda\cdot h_1,\ldots,\lambda\cdot h_d)\f$
represent the same point.
For a point with Cartesian coordinates \f$ (c_0,c_1,\ldots,c_{d-1})\f$ a
possible homogeneous representation is \f$ (c_0,c_1,\ldots,c_{d-1},1)\f$.
Homogeneous coordinates in fact allow to represent
objects in a more general space, the projective space
\f$ \mathbb{P}^d\f$.
In \cgal, we do not compute in projective geometry. Rather, we use
homogeneous coordinates to avoid division operations,
since the additional coordinate can serve as a common denominator.
## Genericity Through Parameterization ##
Almost all the kernel objects (and the corresponding functions) are
templates with a parameter that allows the user to choose the
representation of the kernel objects. A type that is used as an
argument for this parameter must fulfill certain requirements on
syntax and semantics. The list of requirements defines an abstract
kernel concept. For all kernel objects types, the types
`CGAL::Type<Kernel>` and
`Kernel::Type` are identical.
\cgal offers four families of concrete models for the concept Kernel,
two based on the Cartesian representation of
points and two based on the homogeneous representation of points. The
interface of the kernel objects is designed such that it works well
with both Cartesian and homogeneous
representation. For example, points in 2D have a constructor with
three arguments as well (the three homogeneous coordinates of the
point). The common interfaces parameterized with a kernel class allow
one to develop code independent of the chosen representation. We said
"families" of models, because both families are parameterized too.
A user can choose the number type used to represent the coordinates.
For reasons that will become evident later, a kernel class provides
two typenames for number types, namely `Kernel::FT` and `Kernel::RT`.
The type `Kernel::FT` must fulfill the
requirements on what is called a <I>FieldNumberType</I> in \cgal. This
roughly means that `Kernel::FT` is a type for which operations
\f$ +\f$, \f$ -\f$, \f$ *\f$ and \f$ /\f$ are defined with semantics (approximately)
corresponding to those of a field in a mathematical sense. Note that,
strictly speaking, the built-in type `int` does not fulfill the
requirements on a field type, since `int`s correspond to elements
of a ring rather than a field, especially operation \f$ /\f$ is not the
inverse of \f$ *\f$. The requirements on the type `Kernel::RT` are
weaker. This type must fulfill the requirements on what is called a
<I>RingNumberType</I> in \cgal. This roughly means that
`Kernel::RT` is a type for which operations \f$ +\f$, \f$ -\f$, \f$ *\f$ are
defined with semantics (approximately) corresponding to those of a
ring in a mathematical sense.
## Cartesian Kernels ##
With `Cartesian<FieldNumberType>` you can choose a
Cartesian representation of coordinates. When you
choose Cartesian representation you have to
declare at the same time the type of the coordinates. A number type
used with the `Cartesian` representation class should be a
FieldNumberType as described above. As mentioned above, the built-in
type `int` is not a FieldNumberType. However, for some
computations with Cartesian representation, no
division operation is needed, i.e., a `RingNumberType` is sufficient in
this case. With `Cartesian<FieldNumberType>`, both
`Cartesian<FieldNumberType>::FT` and
`Cartesian<FieldNumberType>::RT` are mapped to
`FieldNumberType`.
`Cartesian<FieldNumberType>` uses reference counting internally to
save copying costs. \cgal also provides
`Simple_cartesian<FieldNumberType>`, a kernel that uses
Cartesian representation but no reference
counting. Debugging is easier with
`Simple_cartesian<FieldNumberType>`, since the coordinates are
stored within the class and hence direct access to the coordinates is
possible. Depending on the algorithm, it can also be slightly more or
less efficient than `Cartesian<FieldNumberType>`. Again, in
`Simple_cartesian<FieldNumberType>` both
`Simple_cartesian<FieldNumberType>::FT` and
`Simple_cartesian<FieldNumberType>::RT` are mapped to
`FieldNumberType`.
## Homogeneous Kernels ##
Homogeneous coordinates permit to avoid division operations in
numerical computations, since the additional coordinate can serve as a
common denominator. Avoiding divisions can be useful for exact
geometric computation. With `Homogeneous<RingNumberType>` you can
choose a homogeneous representation for the coordinates of the kernel
objects. As for the Cartesian representation, one
has to declare the type used to store the coordinates. Since the
homogeneous representation does not use divisions, the number type
associated with a homogeneous representation class must be a model for
the weaker concept `RingNumberType` only. However, some operations
provided by this kernel involve divisions, for example computing
squared distances or Cartesian coordinates. To
keep the requirements on the number type parameter of
`Homogeneous` low, the number type
`Quotient<RingNumberType>` is used for operations that require
divisions. This number type can be viewed as an adaptor which turns a
`RingNumberType` into a `FieldNumberType`. It maintains numbers as
quotients, i.e., a numerator and a denominator. With
`Homogeneous<RingNumberType>`,
`Homogeneous<RingNumberType>::FT` is equal to
`Quotient<RingNumberType>`, while
`Homogeneous<RingNumberType>::RT` is equal to
`RingNumberType`.
`Homogeneous<RingNumberType>` uses reference counting internally
to save copying costs. \cgal also provides
`Simple_homogeneous<RingNumberType>`, a kernel that uses
homogeneous representation but no reference
counting. Debugging is easier with
`Simple_homogeneous<RingNumberType>`, since the coordinates are
stored within the class and hence direct access to the coordinates is
possible. Depending on the algorithm, it can also be slightly more or
less efficient than `Homogeneous<RingNumberType>`. Again, in
`Simple_homogeneous<RingNumberType>` the type
`Simple_homogeneous<RingNumberType>::FT` is equal to
`Quotient<RingNumberType>` while
`Simple_homogeneous<RingNumberType>::RT` is equal to
`RingNumberType`.
## Naming Conventions ##
The use of kernel classes not only avoids problems, it also makes all
\cgal classes very uniform. They <B>always</B> consist of:
<OL>
<LI>The <I>capitalized base name</I> of the geometric object, such as
`Point`, `Segment`, or `Triangle`.
<LI>An <I>underscore</I> followed by the <I>dimension</I> of the object,
for example \f$ \_2\f$, \f$ \_3\f$, or \f$ \_d\f$.
<LI>A <I>kernel class</I> as parameter, which itself is
parameterized with a number type, such as
`Cartesian<double>` or
`Homogeneous<leda_integer>`.
</OL>
## Kernel as a Traits Class ##
Algorithms and data structures in the basic library of \cgal are
parameterized by a traits class that subsumes the objects on which the
algorithm or data structure operates as well as the operations to do
so. For most of the algorithms and data structures in the basic
library you can use a kernel as a traits class. For some algorithms
you even do not have to specify the kernel; it is detected
automatically using the types of the geometric objects passed to the
algorithm. In some other cases, the algorithms or data structures
needs more than is provided by the kernel concept. In these cases, a
kernel can not be used as a traits class.
## Choosing a Kernel and Predefined Kernels ##
If you start with integral Cartesian coordinates,
many geometric computations will involve integral numerical values
only. Especially, this is true for geometric computations that
evaluate only predicates, which are tantamount to determinant
computations. Examples are triangulation of point sets and convex hull
computation. In this case, the Cartesian
representation is probably the first choice, even with a ring type.
You might use limited precision integer types like `int` or
`long`, use `double` to present your integers (they have more
bits in their mantissa than an `int` and overflow nicely), or an
arbitrary precision integer type like the wrapper `Gmpz` for the
GMP integers, `leda_integer`, or `MP_Float`. Note, that unless
you use an arbitrary precision ring type, incorrect results might
arise due to overflow.
If new points are to be constructed, for example the
intersection point of two lines, computation of
Cartesian coordinates usually involves divisions.
Hence, one needs to use a `FieldNumberType` with
Cartesian representation, or alternatively, switch
to homogeneous representation. The type `double` is a - though
imprecise - model for `FieldNumberType`. You can also put any
`RingNumberType` into the `Quotient` adaptor to get a field type
which then can be put into `Cartesian`. But using homogeneous
representation on the `RingNumberType` is usually the better option.
Other valid `FieldNumberType`s are `leda_rational` and
`leda_real`.
If it is crucial for you that the computation is reliable, the right
choice is probably a number type that guarantees exact computation.
The `Filtered_kernel` provides a way to apply filtering techniques
\cite cgal:bbp-iayed-01 to achieve a kernel with exact and efficient
predicates. Still other people will prefer the built-in
type <TT>double</TT>, because they need speed and can live with
approximate results, or even algorithms that, from time to time,
crash or compute incorrect results due to accumulated rounding errors.
<b>Predefined kernels.</b>
For the user's convenience, \cgal provides 3 typedefs to generally useful
kernels.
<UL>
<LI>They are all Cartesian kernels.
<LI>They all support constructions of points from <TT>double</TT> Cartesian
coordinates.
<LI>All these 3 kernels provide exact geometric predicates.
<LI>They handle geometric constructions differently:
<UL>
<LI>`Exact_predicates_exact_constructions_kernel`: provides exact
geometric constructions, in addition to exact geometric predicates.
<LI>`Exact_predicates_exact_constructions_kernel_with_sqrt`:
same as `Exact_predicates_exact_constructions_kernel`, but the
number type it provides
(`Exact_predicates_exact_constructions_kernel_with_sqrt::FT`)
supports the square root operation exactly
\footnote{Currently it requires having either LEDA or CORE installed}.
<LI>`Exact_predicates_inexact_constructions_kernel`: provides exact
geometric predicates, but geometric constructions may be inexact due to
round-off errors. It is however enough for most \cgal algorithms, and
faster than both `Exact_predicates_exact_constructions_kernel` and
`Exact_predicates_exact_constructions_kernel_with_sqrt`.
</UL>
</UL>
# Kernel Geometry #
## Points and Vectors ##
In \cgal, we strictly distinguish between points, vectors and directions.
A <I>point</I> is a point in the Euclidean space
\f$ \E^d\f$, a <I>vector</I> is the difference of two points \f$ p_2\f$, \f$ p_1\f$
and denotes the direction and the distance from \f$ p_1\f$ to \f$ p_2\f$ in the
vector space \f$ \R^d\f$, and a <I>direction</I> is a vector where we forget
about its length.
They are different mathematical concepts. For example, they behave
different under affine transformations and an addition of two
points is meaningless in affine geometry. By putting them in different
classes we not only get cleaner code, but also type checking by the
compiler which avoids ambiguous expressions. Hence, it pays twice to
make this distinction.
\cgal defines a symbolic constant `ORIGIN` of type `Origin`
which denotes the point at the origin. This constant is used in the conversion
between points and vectors. Subtracting it from a point \f$ p\f$ results in the
locus vector of \f$ p\f$.
\code{.cpp}
Point_2< Cartesian<double> > p(1.0, 1.0), q;
Vector_2< Cartesian<double> > v;
v = p - ORIGIN;
q = ORIGIN + v;
assert( p == q );
\endcode
In order to obtain the point corresponding to a vector \f$ v\f$ you simply
have to add \f$ v\f$ to `ORIGIN`. If you want to determine
the point \f$ q\f$ in the middle between two points \f$ p_1\f$ and \f$ p_2\f$, you can write\footnote{you might call `midpoint(p_1,p_2)` instead}
\code{.cpp}
q = p_1 + (p_2 - p_1) / 2.0;
\endcode
Note that these constructions do not involve any performance overhead for
the conversion with the currently available representation classes.
## Kernel Objects ##
Besides points (`Point_2<Kernel>`, `Point_3<Kernel>`, `Point_d<Kernel>`),
vectors (`Vector_2<Kernel>`, `Vector_3<Kernel>`), and
directions (`Direction_2<Kernel>`, `Direction_3<Kernel>`),
\cgal provides lines, rays, segments, planes,
triangles, tetrahedra, iso-rectangles, iso-cuboids, circles and spheres.
Lines (`Line_2<Kernel>`, `Line_3<Kernel>`) in \cgal are oriented. In
two-dimensional space, 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 (`Ray_2<Kernel>`, `Ray_3<Kernel>`) 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 (`Segment_2<Kernel>`,
`Segment_3<Kernel>`) 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.
Planes are affine subspaces of dimension two in \f$ \E^3\f$, passing through
three points, or a point and a line, ray, or segment.
\cgal provides a correspondence between any plane in the ambient
space \f$ \E^3\f$ and the embedding of \f$ \E^2\f$ in that space.
Just like lines, planes are oriented and partition space into a positive side
and a negative side.
In \cgal, there are no special classes for half-spaces. Half-spaces in 2D and
3D are supposed to be represented by oriented lines and planes, respectively.
Concerning polygons and polyhedra, the kernel provides triangles,
iso-oriented rectangles, iso-oriented cuboids and tetrahedra.
More complex polygons\footnote{Any sequence of points can be seen as a (not necessary simple) polygon or polyline. This view is used frequently in the basic library as well.}
and polyhedra or polyhedral surfaces can be obtained
from the basic library (`Polygon_2`, `Polyhedron_3`),
so they are not part of the kernel.
As with any Jordan curves, triangles, iso-oriented rectangles and circles
separate the plane into two regions, one bounded and one unbounded.
## Orientation and Relative Position ##
Geometric objects in \cgal have member functions that test the
position of a point relative to the object. Full dimensional objects
and their boundaries are represented by the same type,
e.g. half-spaces and hyperplanes are not distinguished, neither are balls and
spheres and discs and circles. Such objects split the ambient space into two
full-dimensional parts, a bounded part and an unbounded part
(e.g. circles), or two unbounded parts (e.g. hyperplanes). By default these
objects are oriented, i.e., one of the resulting parts is called the
positive side, the other one is called the negative side. Both of
these may be unbounded.
For these objects there is a function `oriented_side()` that
determines whether a test point is on the positive side, the negative
side, or on the oriented boundary. These function returns a value of type
`Oriented_side`.
Those objects that split the space in a bounded and an unbounded part, have
a member function `bounded_side()` with return type
`Bounded_side`.
If an object is lower dimensional, e.g. a triangle in three-dimensional
space or a segment in two-dimensional space, there is only a test whether a
point belongs to the object or not. This member function, which takes a
point as an argument and returns a Boolean value, is called `has_on()`
# Predicates and Constructions #
## Predicates ##
Predicates are at the heart of a geometry kernel. They are basic units
for the composition of geometric algorithms and encapsulate decisions.
Hence their correctness is crucial for the control flow and hence for
the correctness of an implementation of a geometric algorithm. \cgal uses
the term predicate in a generalized sense. Not only components returning a
Boolean value are called predicates but also components returning an
enumeration type like a `Comparison_result` or an `Orientation`.
We say components, because predicates are implemented both as functions and
function objects (provided by a kernel class).
\cgal provides predicates for the orientation of point
sets (`orientation`, `leftturn`, `rightturn`, `collinear`,
`coplanar`), for comparing points according to some given order,
especially for comparing Cartesian coordinates
(e.g. `lexicographically_xy_smaller`), in-circle and in-sphere tests,
and predicates to compare distances.
## Constructions ##
Functions and function objects that generate objects that are neither
of type `bool` nor enum types are called constructions.
Constructions involve computation of new numerical values and may be
imprecise due to rounding errors unless a kernel with an exact number type is
used.
Affine transformations (`Aff_transformation_2<Kernel>`,
`Aff_transformation_3<Kernel>`) allow to generate new object instances under
arbitrary affine transformations. These transformations include translations,
rotations (in 2D only) and scaling. Most of the geometric objects in a
kernel have a member function `transform(Aff_transformation t)`
which applies the transformation to the object instance.
\cgal also provides a set of functions that detect or compute the
intersection
between objects of the 2D kernel, and many objects in the 3D kernel,
and functions to calculate their
squared distance.
Moreover, some member functions of kernel objects are constructions.
So there are routines that compute the square of the Euclidean distance, but no
routines that compute the distance itself. Why?
First of all, the two values can be derived from each other quite easily (by
taking the square root or taking the square). So, supplying only the one and
not the other is only a minor inconvenience for the user.
Second, often either value can be used. This is for example the case when
(squared) distances are compared.
Third, the library wants to stimulate the use of the squared distance instead
of the distance. The squared distance can be computed in more cases and the
computation is cheaper.
We do this by not providing the perhaps more natural routine,
The problem of a distance routine is that it needs the `sqrt`
operation.
This has two drawbacks:
<UL>
<LI>The `sqrt` operation can be costly. Even if it is not very costly for
a specific number type and platform, avoiding it is always cheaper.
<LI>There are number types on which no `sqrt` operation is defined,
especially integer types and rationals.
</UL>
## Polymorphic Return Values ##
Some functions can return different types of objects. A typical
\cpp solution to this problem is to derive all possible return
types from a common base class, to return a pointer to this
class and to perform a dynamic cast on this pointer. The class
`Object` provides an abstraction.
An object `obj` of the class `Object` can
represent an arbitrary class. The only operations it provides is
to make copies and assignments, so that you can put them in lists
or arrays. Note that `Object` is NOT a common base class for the
elementary classes. Therefore, there is no
automatic conversion from these classes to `Object`. Rather
this is done with the global function `make_object()`. This
encapsulation mechanism requires the use of
`object_cast` to access the encapsulated class (a less
efficient way, which is now discouraged, used to be to
use the `assign` function).
HEADING:Example
--------------
In the following example, the object class is used as return value for the
intersection computation, as there are possibly different return values.
\code{.cpp}
typedef Cartesian<double> K;
typedef K::Point_2 Point_2;
typedef K::Segment_2 Segment_2;
Segment_2 segment_1, segment_2;
std::cin >> segment_1 >> segment_2;
Object obj = intersection(segment_1, segment_2);
if (const Point_2 *point = object_cast<Point_2>(&obj)) {
// do something with point
} else if (const Segment_2 *segment = object_cast<Segment_2>(&obj)) {
// do something with segment
} else {
// there was no intersection
}
\endcode
The intersection routine itself looks roughly as follows:
\code{.cpp}
template < class Kernel >
Object intersection(Segment_2<Kernel> s1, Segment_2<Kernel> s2)
{
if (intersection in a point) {
Point_2<Kernel> p = ... ;
return make_object(p);
} else if (intersection in a segment) {
Segment_2<Kernel> s = ... ;
return make_object(s);
}
return Object();
}
\endcode
## Constructive Predicates ##
For testing where a point \f$ p\f$ lies with respect to a plane defined by three
points \f$ q\f$, \f$ r\f$ and \f$ s\f$, one may be tempted to construct the plane
`Plane_3<Kernel>(q,r,s)` and use the method `oriented_side(p)`.
This may pay off if many tests with respect to the plane are made.
Nevertheless, unless the number type is exact, the constructed plane
is only approximated, and round-off errors may lead
`oriented_side(p)` to return an orientation
which is different from the orientation of \f$ p\f$, \f$ q\f$, \f$ r\f$,
and \f$ s\f$.
In \cgal, we provide predicates in which such
geometric decisions are made directly with a reference to the input points
\f$ p\f$, \f$ q\f$, \f$ r\f$, \f$ s\f$, without an intermediary object like a plane.
For the above test, the recommended way to get the result is to use
`orientation(p,q,r,s)`. For exact number types, the situation is different.
If several tests are to be made with the same
plane, it pays off to construct the plane and to use `oriented_side(p)`.
\section sectionextensiblekernel Extensible Kernel
This manual section describe how users can plug user defined
geometric classes in existing \cgal kernels. This is best
illustrated by an example.
## Introduction ##
\cgal defines the concept of a geometry kernel. Such a kernel provides types,
construction objects and generalized predicates. Most implementations
of Computational Geometry algorithms and data structures in the basic
library of \cgal were done in a way that classes or functions can be
parametrized with a geometric traits class.
In most cases this geometric traits class must be a model of the \cgal geometry
kernel concept (but there are some exceptions).
## An Extensive Example ##
Assume you have the following point class, where the coordinates are
stored in an array of `doubles`, where we have another data member
`color`, which shows up in the constructor.
\cgalexample{MyPointC2.h}
As said earlier the class is pretty minimalistic, for
example it has no `bbox()` method. One
might assume that a basic library algorithm which computes
a bounding box (e.g, to compute the bounding box of a polygon),
will not compile. Luckily it will, because it does not
use of member functions of geometric objects, but it makes
use of the functor `Kernel::Construct_bbox_2`.
To make the right thing happen with `MyPointC2` we
have to provide the following functor.
\cgalexample{MyConstruct_bbox_2.h}
Things are similar for random access to the Cartesian
coordinates of a point. As the coordinates are stored
in an array of `doubles` we can use `double*` as
random access iterator.
\cgalexample{MyConstruct_coord_iterator.h}
The last functor we have to provide is the one which constructs
points. That is you are not forced to add the constructor
with the `Origin` as parameter to your class, nor the constructor with
homogeneous coordinates.
The functor is a kind of glue layer between the \cgal algorithms
and your class.
\cgalexample{MyConstruct_point_2.h}
Now we are ready to put the puzzle together. We won't explain it in
detail, but you see that there are `typedefs` to the new point
class and the functors. All the other types are inherited.
\cgalexample{MyKernel.h}
Finally, we give an example how this new kernel can be used.
Predicates and constructions work with the new point, they
can be a used to construct segments and triangles with, and
data structures from the Basic Library, as the Delaunay
triangulation work with them.
The kernel itself can be
made robust by plugging it in the `Filtered_kernel`.
\cgalexample{MyKernel.cpp}
## Limitations ##
The point class must have member functions `x()` and `y()`
(and `z()` for the 3d point). We will probably
introduce function objects that take care of coordinate
access.
As we enforce type equality between `MyKernel::Point_2` and `Point_2<MyKernel>`,
the constructor with the color as third argument is not available.
\section sectionprojectiontraits Projection Traits Classes
It is sometimes useful to apply 2D algorithms to the projection of 3D points on
a plane. Examples are
triangulated terrains, which are points with elevation, or surface
reconstruction from parallel slices, where one wants to check the simplicity
or orientation of polygons.
For this purpose \cgal provides several projection traits classes,
which are a model of traits class concepts of 2D triangulations,
2D polygon and 2D convex hull traits classes. The projection traits classes
are listed in the "<I>Is Model for the Concepts</I>" sections of the concepts.
# Design and Implementation History #
At a meeting at Utrecht University in January 1995,
Olivier Devillers, Andreas Fabri, Wolfgang Freiseisen,
Geert-Jan Giezeman, Mark Overmars, Stefan Schirra, Otfried Schwarzkopf
(now Otfried Cheong), and Sven Sch&ouml;nherr
discussed the foundations of the \cgal kernel.
Many design and software engineering issues were addressed,
e.g. naming conventions, coupling of classes
(flat versus deep class hierarchy),
memory allocation, programming conventions, mutability of
atomic objects, points and vectors, storing additional information,
orthogonality of operations on the kernel objects,
viewing non-constant-size objects like polygons as
dynamic data structures (and hence not as part of the (innermost) kernel).
The people attending the meeting delegated the compilation of
a draft specification to Stefan Schirra.
The resulting draft specification was intentionally modeled on \cgal's
precursors \protocgal and \plageo as well as on the geometric part of \leda.
The specification already featured coexistence of
Cartesian and
homogeneous representation of point/vector data and parameterization
by number type(s).
During the discussion of the draft a kernel design group was formed.
The members of this group were Andreas Fabri, Geert-Jan Giezeman,
Lutz Kettner, Stefan Schirra, and Sven Sch&ouml;nherr.
The work of the kernel design group led to significant changes and
improvements of the original design, e.g. the strong separation between
points and vectors. Probably the most important enhancement was the design
of a common superstructure for the previously uncoupled
Cartesian and
homogeneous representations. One can say, that the kernel was designed
by this group.
The kernel was later revised based on suggestions by Herv&eacute; Br&ouml;nnimann,
Bernd G&auml;rtner, Michael Hoffmann, and Lutz Kettner.
A first version of the kernel was internally made available at the beginning
of the \cgal-project (<span class="textsc">esprit ltr iv</span> project number 21957).
Since then many more people contributed to the evolution of the kernel
through discussions on the \cgal mailing lists.
The implementation based on
Cartesian representation was (initially) provided
by Andreas Fabri, the homogeneous representation (initially) by Stefan Schirra.
Intersection and distance computations were implemented by Geert-Jan Giezeman.
Further work has been done by Susan Hert on the overall maintenance of the
kernel.
Philippe Guigue has provided efficient intersection tests for 3D triangles.
Andreas Fabri, Michael Hoffmann and Sylvain Pion have improved the support for
the extensibility and adaptability of the kernel. Pedro Machado
Manh&atilde;es de Castro and Monique Teillaud introduced 3D circles. In 2010,
Pierre Alliez, St&eacute;phane Tayeb and Camille Wormser added intersection constructions
for 3D triangles and efficient intersection tests for bounding boxes.
## Acknowledgment ##
This work was supported
by the Graduiertenkolleg 'Algorithmische Diskrete Mathematik',
under grant DFG We 1265/2-1,
and by ESPRIT IV Long Term Research Projects No. 21957 (CGAL)
and No. 28155 (GALIA).
*/
} /* namespace CGAL */

View File

@ -0,0 +1,30 @@
/// \defgroup PkgKernel23 2D and 3D Linear Geometry Kernel
/// \defgroup PkgKernel23Concepts Concepts
/// \ingroup PkgKernel23
/// \defgroup PkgKernel23ConceptsGeomObject Kernel Geometric Object Concepts
/// \ingroup PkgKernel23Concepts
/// \defgroup PkgKernel23ConceptsFunctionObjects Kernel Function Object Concepts
/// \ingroup PkgKernel23Concepts
/// \defgroup kernel_predef Predefined Kernels
/// \ingroup PkgKernel23
/// Kernels that come with \cgal
/*!
\addtogroup PkgKernel23
\todo check generated documentation
\PkgDescriptionBegin{2D and 3D Linear Geometry Kernel}
\PkgPicture{pointSegmentTriangle.png}
\PkgAuthor{Herv&eacute; Br&ouml;nnimann, Andreas Fabri, Geert-Jan Giezeman, Susan Hert, Michael Hoffmann, Lutz Kettner, Sylvain Pion, and Stefan Schirra}
\PkgDesc{This package contains kernels each containing objects of constant size, such as point, vector, direction, line, ray, segment, circle as well as predicates and constructions for these objects. The kernels mainly differ in the way they handle robustness issues.}
\PkgSince{0.9}
\cgalbib{ cgal:bfghhkps-lgk23-12 }
\license{ Label \ref licensesLGPL "LGPL" }
\PkgDescriptionEnd
*/

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 991 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B