mirror of https://github.com/CGAL/cgal
Add Kernel_d doc.
This commit is contained in:
parent
6783a9410b
commit
edc8892f74
|
|
@ -3010,6 +3010,65 @@ Kernel_23/include/CGAL/internal/Projection_traits_3.h -text
|
|||
Kernel_23/test/Kernel_23/include/CGAL/_Result_of_kernel.h -text
|
||||
Kernel_23/test/Kernel_23/overload_bug.cpp -text
|
||||
Kernel_23/test/Kernel_23/test_result_of.cpp -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Cartesian_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Homogeneous_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Aff_transformation_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Direction_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Hyperplane_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Iso_box_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Line_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Point_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Ray_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Segment_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Sphere_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Vector_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Linear_algebraCd.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/Linear_algebraHd.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/constructions_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/intersections_d.h -text
|
||||
Kernel_d/doc/Kernel_d/CGAL/predicates_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Classified.txt -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Affine_rank_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Affinely_independent_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--CartesianConstIterator_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Center_of_sphere_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Compare_lexicographically_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Component_accessor_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Compute_coordinate_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--ConstructCartesianConstIterator_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Contained_in_affine_hull_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Contained_in_linear_hull_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Contained_in_simplex_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Equal_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Has_on_positive_side_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Intersect_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Less_coordinate_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Less_lexicographically_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Less_or_equal_lexicographically_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Lift_to_paraboloid_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Linear_base_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Linear_rank_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Linearly_independent_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Midpoint_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Orientation_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Oriented_side_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Orthogonal_vector_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Point_dimension_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Point_of_sphere_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Point_to_vector_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Project_along_d_axis_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Side_of_bounded_sphere_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Side_of_oriented_sphere_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Squared_distance_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Value_at_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel--Vector_to_point_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/LinearAlgebraTraits_d.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Matrix.h -text
|
||||
Kernel_d/doc/Kernel_d/Concepts/Vector.h -text
|
||||
Kernel_d/doc/Kernel_d/Kernel_d.txt -text
|
||||
Kernel_d/doc/Kernel_d/PackageDescription.txt -text
|
||||
Kernel_d/doc/Kernel_d/fig/hypercube.png -text svneol=unset#image/png
|
||||
Kernel_d/doc_tex/Kernel_d/hypercube.png -text
|
||||
Kernel_d/doc_tex/Kernel_d_ref/Kernel_Compute_coordinate_d.tex -text
|
||||
Kernel_d/doc_tex/Kernel_d_ref/Kernel_Less_coordinate_d.tex -text
|
||||
|
|
|
|||
|
|
@ -468,12 +468,24 @@ namespace for the XML file to be processed properly. -->
|
|||
<string name="STRIP_FROM_PATH">../Algebraic_kernel_d/doc/Algebraic_kernel_d/</string>
|
||||
<string name="STRIP_FROM_INC_PATH">../Algebraic_kernel_d/doc/Algebraic_kernel_d/</string>
|
||||
<string name="GENERATE_TAGFILE">./tags/Algebraic_kernel_d.tag</string>
|
||||
<string name="EXAMPLE_PATH">../Algebraic_kernel_d/examples</string>
|
||||
<string name="IMAGE_PATH">../Algebraic_kernel_d/doc/Algebraic_kernel_d/fig</string>
|
||||
<bool name="SORT_GROUP_NAMES">true</bool>
|
||||
</doxygen>
|
||||
</project>
|
||||
|
||||
<project>
|
||||
<name>dD Geometry Kernel</name>
|
||||
<input>../Kernel_d/doc</input>
|
||||
<doxygen>
|
||||
<string name="STRIP_FROM_PATH">../Kernel_d/doc/Kernel_d/</string>
|
||||
<string name="STRIP_FROM_PATH">../Kernel_d/doc/Kernel_d/</string>
|
||||
<string name="STRIP_FROM_INC_PATH">../Kernel_d/doc/Kernel_d/</string>
|
||||
<string name="GENERATE_TAGFILE">./tags/Kernel_d.tag</string>
|
||||
<string name="EXAMPLE_PATH">../Kernel_d/examples</string>
|
||||
<string name="IMAGE_PATH">../Kernel_d/doc/Kernel_d/fig</string>
|
||||
<bool name="SORT_GROUP_NAMES">true</bool>
|
||||
</doxygen>
|
||||
</project>
|
||||
|
||||
<project>
|
||||
<name>Convex Decomposition of Polyhedra</name>
|
||||
|
|
@ -1141,6 +1153,7 @@ namespace for the XML file to be processed properly. -->
|
|||
<item>../Circular_kernel_2/doc/Circular_kernel_2/fig</item>
|
||||
<item>../Circular_kernel_3/doc/Circular_kernel_3/fig</item>
|
||||
<item>../Algebraic_kernel_d/doc/Algebraic_kernel_d/fig</item>
|
||||
<item>../Kernel_d/doc/Kernel_d/fig</item>
|
||||
<item>../Point_set_2/doc/Point_set_2/fig</item>
|
||||
<item>../SearchStructures/doc/SearchStructures/fig</item>
|
||||
<item>../Polytope_distance_d/doc/Polytope_distance_d/fig</item>
|
||||
|
|
@ -1212,6 +1225,7 @@ namespace for the XML file to be processed properly. -->
|
|||
<item>./tags/Circular_kernel_2.tag=../../CGAL.CGAL.2D-Circular-Geometry-Kernel/html</item>
|
||||
<item>./tags/Circular_kernel_3.tag=../../CGAL.CGAL.3D-Spherical-Geometry-Kernel/html</item>
|
||||
<item>./tags/Algebraic_kernel_d.tag=../../CGAL.CGAL.Algebraic-Kernel/html</item>
|
||||
<item>./tags/Kernel_d.tag=../../CGAL.CGAL.dD-Geometry-Kernel/html</item>
|
||||
<item>./tags/Point_set_2.tag=../../CGAL.CGAL.2D-Range-and-Neighbor-Search/html</item>
|
||||
<item>./tags/SearchStructures.tag=../../CGAL.CGAL.dD-Range-and-Segment-Trees/html</item>
|
||||
<item>./tags/Polyhedron.tag=../../CGAL.CGAL.3D-Polyhedral-Surface/html</item>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernels
|
||||
|
||||
A model for `Kernel_d` that uses Cartesian coordinates to represent the
|
||||
geometric objects. In order for `Cartesian_d` to model Euclidean geometry
|
||||
in \f$ E^d\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_d
|
||||
|
||||
\sa `CGAL::Homogeneous_d<RingNumberType>`
|
||||
|
||||
*/
|
||||
template< typename FieldNumberType >
|
||||
class Cartesian_d {
|
||||
public:
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Cartesian_d */
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernels
|
||||
|
||||
A model for a `Kernel_d` using homogeneous coordinates to represent the
|
||||
geometric objects. In order for `Homogeneous` to model Euclidean geometry
|
||||
in \f$ E^d\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 `RT`
|
||||
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_d
|
||||
|
||||
\sa `CGAL::Cartesian_d<FieldumberType>`
|
||||
|
||||
*/
|
||||
template< typename RingNumberType >
|
||||
class Homogeneous {
|
||||
public:
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Homogeneous */
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelObjs
|
||||
|
||||
An instance of the data type `Aff_transformation_d<Kernel>` is an
|
||||
affine transformation of \f$ d\f$-dimensional space. It is specified by a
|
||||
square matrix \f$ M\f$ of dimension \f$ d + 1\f$. All entries in the last row of
|
||||
`M` except the diagonal entry must be zero; the diagonal entry
|
||||
must be non-zero. A point \f$ p\f$ with homogeneous coordinates \f$ (p[0],
|
||||
\ldots, p[d])\f$ can be transformed into the point `p.transform(A)`
|
||||
= \f$ Mp\f$, where `A` is an affine transformation created from `M`
|
||||
by the constructors below.
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
||||
Affine Transformations are implemented by matrices of number type
|
||||
`RT` as a handle type. All operations like creation,
|
||||
initialization, input and output on a transformation \f$ t\f$ take time
|
||||
\f$ O(t.dimension()^2)\f$. `dimension()` takes constant time.
|
||||
The operations for inversion and composition have the cubic costs of
|
||||
the used matrix operations. The space requirement is
|
||||
\f$ O(t.dimension()^2)\f$.
|
||||
|
||||
*/
|
||||
template< typename Kernel >
|
||||
class Aff_transformation_d {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
the linear algebra layer.
|
||||
*/
|
||||
typedef Hidden_type LA;
|
||||
|
||||
/*!
|
||||
the matrix type.
|
||||
*/
|
||||
typedef Hidden_type Matrix;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
introduces some
|
||||
transformation.
|
||||
*/
|
||||
Aff_transformation_d<Kernel>();
|
||||
|
||||
/*!
|
||||
introduces the identity transformation in
|
||||
\f$ d\f$-dimensional space.
|
||||
*/
|
||||
Aff_transformation_d<Kernel>(int d,
|
||||
Identity_transformation);
|
||||
|
||||
/*!
|
||||
introduces the
|
||||
transformation of \f$ d\f$-space specified by matrix \f$ M\f$.
|
||||
|
||||
\pre `M` is a square matrix of dimension \f$ d + 1\f$ where entries in the last row of `M` except the diagonal entry must be zero; the diagonal entry must be non-zero.
|
||||
*/
|
||||
Aff_transformation_d<Kernel>(Matrix M);
|
||||
|
||||
/*!
|
||||
introduces the transformation of \f$ d\f$-space
|
||||
specified by a diagonal matrix with entries `set [start,end)` on
|
||||
the diagonal (a scaling of the space).
|
||||
|
||||
\pre `set [start,end)` is a vector of dimension \f$ d+1\f$.
|
||||
*/
|
||||
template <typename Forward_iterator>
|
||||
Aff_transformation_d<Kernel>(Scaling, Forward_iterator start,
|
||||
Forward_iterator end);
|
||||
|
||||
/*!
|
||||
introduces the translation by vector \f$ v\f$.
|
||||
*/
|
||||
Aff_transformation_d<Kernel>(Translation, Vector_d<Kernel>
|
||||
v);
|
||||
|
||||
/*!
|
||||
returns a scaling by a scale factor `num/den`.
|
||||
|
||||
\pre `den !=0 `.
|
||||
*/
|
||||
Aff_transformation_d<Kernel>(int d, Scaling, RT num, RT
|
||||
den);
|
||||
|
||||
/*!
|
||||
returns a planar rotation
|
||||
with sine and cosine values `sin_num/den` and `cos_num/den`
|
||||
in the plane spanned by the base vectors \f$ b_{e1}\f$ and \f$ b_{e2}\f$ in
|
||||
\f$ d\f$-space. Thus the default use delivers a planar rotation in the
|
||||
\f$ x\f$-\f$ y\f$ plane.
|
||||
|
||||
\pre \f$ sin_num^2 + cos_num^2 = den^2\f$ and \f$ 0 \leq e_1 < e_2 < d\f$.
|
||||
\pre `den != 0`.
|
||||
|
||||
*/
|
||||
Aff_transformation_d<Kernel>(int d, Rotation, RT sin_num, RT
|
||||
cos_num, RT den, int e1 = 0, int e2 = 1);
|
||||
|
||||
/*!
|
||||
returns a planar
|
||||
rotation within a two-dimensional linear subspace. The subspace is
|
||||
spanned by the base vectors \f$ b_{e1}\f$ and \f$ b_{e2}\f$ in \f$ d\f$-space. The
|
||||
rotation parameters are given by the \f$ 2\f$-dimensional direction
|
||||
`dir`, such that the difference between the sines and cosines of
|
||||
the rotation given by `dir` and the approximated rotation are at
|
||||
most `num/den` each.
|
||||
\pre `dir.dimension()==2`, `!dir.is_degenerate()` and `num < den` is positive, `den != 0`, \f$ 0 \leq e_1 < e_2 < d\f$.
|
||||
*/
|
||||
Aff_transformation_d<Kernel>(int d, Rotation, Direction_d<Kernel>
|
||||
dir, RT num, RT den, int e1 = 0, int e2 = 1);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
the dimension of the underlying space
|
||||
*/
|
||||
int dimension() ;
|
||||
|
||||
/*!
|
||||
returns the transformation matrix
|
||||
|
||||
*/
|
||||
const Matrix& matrix() ;
|
||||
|
||||
/*!
|
||||
returns the inverse
|
||||
transformation.
|
||||
|
||||
\pre `t.matrix()` is invertible.
|
||||
*/
|
||||
Aff_transformation_d<Kernel> inverse() ;
|
||||
|
||||
/*!
|
||||
composition of transformations. Note
|
||||
that transformations are not necessarily commutative. `t*s` is
|
||||
the transformation which transforms first by `t` and then by
|
||||
`s`.
|
||||
*/
|
||||
Aff_transformation_d<Kernel> operator*(const
|
||||
Aff_transformation_d<Kernel>& s) ;
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Aff_transformation_d */
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelObjs
|
||||
|
||||
A `Direction_d` is a vector in the \f$ d\f$-dimensional vector space
|
||||
where we forget about its length. We represent directions in
|
||||
\f$ d\f$-dimensional space as a tuple \f$ (h_0,\ldots,h_d)\f$ of variables of
|
||||
type `RT` which we call the homogeneous coordinates of the
|
||||
direction. The coordinate \f$ h_d\f$ must be positive. The Cartesian
|
||||
coordinates of a direction are \f$ c_i = h_i/h_d\f$ for \f$ 0 \le i < d\f$,
|
||||
which are of type `FT`. Two directions are equal if their
|
||||
Cartesian coordinates are positive multiples of each other. Directions
|
||||
are in one-to-one correspondence to points on the unit sphere.
|
||||
|
||||
Downward compatibility
|
||||
--------------
|
||||
|
||||
We provide the operations of the lower dimensional interface `dx()`,
|
||||
`dy()`, `dz()`.
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
||||
Directions are implemented by arrays of integers as an item type. All
|
||||
operations like creation, initialization, tests, inversion, input and
|
||||
output on a direction \f$ d\f$ take time \f$ O(d.\mathit{dimension}())\f$.
|
||||
`dimension()`, coordinate access and conversion take constant
|
||||
time. The space requirement is \f$ O(d.\mathit{dimension}())\f$.
|
||||
|
||||
*/
|
||||
template< typename Kernel >
|
||||
class Direction_d {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
the linear algebra layer.
|
||||
*/
|
||||
typedef Hidden_type LA;
|
||||
|
||||
/*!
|
||||
|
||||
a read-only iterator for the deltas of `dir`.
|
||||
*/
|
||||
typedef Hidden_type Delta_const_iterator;
|
||||
|
||||
/*!
|
||||
construction tag.
|
||||
*/
|
||||
typedef Hidden_type Base_direction;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
introduces a variable `dir` of
|
||||
type `Direction_d<Kernel>`.
|
||||
*/
|
||||
Direction_d<Kernel>();
|
||||
|
||||
/*!
|
||||
|
||||
introduces a variable `dir` of type `Direction_d<Kernel>`
|
||||
initialized to the direction of `v`.
|
||||
*/
|
||||
Direction_d<Kernel>(Vector_d<Kernel> v);
|
||||
|
||||
/*!
|
||||
|
||||
introduces a variable `dir` of type `Direction_d<Kernel>` in
|
||||
dimension `d` with representation tuple `set [first,last)`.
|
||||
\pre `d` is nonnegative, `[first,last)` has `d` elements.
|
||||
\requires The value type of `InputIterator` is `RT`.
|
||||
*/
|
||||
template <class InputIterator>
|
||||
Direction_d<Kernel>(int d, InputIterator first, InputIterator last);
|
||||
|
||||
/*!
|
||||
returns
|
||||
a variable `dir` of type `Direction_d<Kernel>` initialized to the
|
||||
direction of the \f$ i\f$-th base vector of dimension \f$ d\f$.
|
||||
|
||||
\pre \f$ 0 \leq i < d\f$.
|
||||
*/
|
||||
Direction_d<Kernel>(int d, Base_direction, int i);
|
||||
|
||||
/*!
|
||||
|
||||
introduces a variable `dir` of type `Direction_d<Kernel>` in
|
||||
\f$ 2\f$-dimensional space.
|
||||
*/
|
||||
Direction_d<Kernel>(RT x, RT y);
|
||||
|
||||
/*!
|
||||
|
||||
introduces a variable `dir` of type `Direction_d<Kernel>` in
|
||||
\f$ 3\f$-dimensional space.
|
||||
*/
|
||||
Direction_d<Kernel>(RT x, RT y, RT z);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
|
||||
returns the dimension of `dir`.
|
||||
*/
|
||||
int dimension() ;
|
||||
|
||||
/*!
|
||||
|
||||
returns the \f$ i\f$-th component of `dir`.
|
||||
\pre \f$ 0 \leq i < d\f$.
|
||||
*/
|
||||
RT delta(int i) ;
|
||||
|
||||
/*!
|
||||
|
||||
returns the \f$ i\f$-th delta of `dir`.
|
||||
\pre \f$ 0 \leq i < d\f$.
|
||||
*/
|
||||
RT operator[](int i) ;
|
||||
|
||||
/*!
|
||||
|
||||
returns an iterator pointing to the first delta of `dir`.
|
||||
*/
|
||||
Delta_const_iterator deltas_begin() ;
|
||||
|
||||
/*!
|
||||
|
||||
returns an iterator pointing beyond the last delta of `dir`.
|
||||
*/
|
||||
Delta_const_iterator deltas_end() ;
|
||||
|
||||
/*!
|
||||
|
||||
returns a vector pointing in direction `dir`.
|
||||
*/
|
||||
Vector_d<Kernel> vector() ;
|
||||
|
||||
/*!
|
||||
|
||||
returns true iff `dir.delta(i)==0` for all \f$ 0\leq i < d\f$.
|
||||
*/
|
||||
bool is_degenerate() ;
|
||||
|
||||
/*!
|
||||
|
||||
returns \f$ t(p)\f$.
|
||||
*/
|
||||
Direction_d<Kernel> transform(const Aff_transformation_d<Kernel>& t) ;
|
||||
|
||||
/*!
|
||||
|
||||
returns the direction opposite to `dir`.
|
||||
*/
|
||||
Direction_d<Kernel> opposite() ;
|
||||
|
||||
/*!
|
||||
|
||||
returns the direction opposite to `dir`.
|
||||
*/
|
||||
Direction_d<Kernel> operator- () ;
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Direction_d */
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,237 @@
|
|||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelObjs
|
||||
|
||||
An instance of data type `Hyperplane_d` is an oriented hyperplane
|
||||
in \f$ d\f$ - dimensional space. A hyperplane \f$ h\f$ is represented by
|
||||
coefficients \f$ (c_0,c_1,\ldots,c_d)\f$ of type `RT`. At least one of
|
||||
\f$ c_0\f$ to \f$ c_{ d - 1 }\f$ must be non-zero. The plane equation is
|
||||
\f$ \sum_{ 0 \le i < d } c_i x_i + c_d = 0\f$, where \f$ x_0\f$ to \f$ x_{d-1}\f$ are
|
||||
Cartesian point coordinates. For a particular \f$ x\f$ the sign of \f$ \sum_{
|
||||
0 \le i < d } c_i x_i + c_d\f$ determines the position of a point \f$ x\f$
|
||||
with respect to the hyperplane (on the hyperplane, on the negative
|
||||
side, or on the positive side).
|
||||
|
||||
There are two equality predicates for hyperplanes. The (weak) equality
|
||||
predicate (`weak_equality`) declares two hyperplanes equal if they
|
||||
consist of the same set of points, the strong equality predicate
|
||||
(`operator==`) requires in addition that the negative halfspaces
|
||||
agree. In other words, two hyperplanes are strongly equal if their
|
||||
coefficient vectors are positive multiples of each other and they are
|
||||
(weakly) equal if their coefficient vectors are multiples of each
|
||||
other.
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
||||
Hyperplanes are implemented by arrays of integers as an item type.
|
||||
All operations like creation, initialization, tests, vector
|
||||
arithmetic, input and output on a hyperplane \f$ h\f$ take time
|
||||
\f$ O(h.dimension())\f$. coordinate access and `dimension()` take
|
||||
constant time. The space requirement is \f$ O(h.dimension())\f$.
|
||||
|
||||
*/
|
||||
template< typename Kernel >
|
||||
class Hyperplane_d {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
the linear algebra layer.
|
||||
*/
|
||||
typedef Hidden_type LA;
|
||||
|
||||
/*!
|
||||
a read-only iterator for the
|
||||
coefficients.
|
||||
*/
|
||||
typedef Hidden_type Coefficient_const_iterator;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
introduces a variable
|
||||
`h` of type `Hyperplane_d<Kernel>`.
|
||||
*/
|
||||
Hyperplane_d<Kernel>();
|
||||
|
||||
/*!
|
||||
introduces a
|
||||
variable `h` of type `Hyperplane_d<Kernel>` initialized to the
|
||||
hyperplane with coefficients `set [first,last)` and `D`.
|
||||
\pre `size [first,last) == d`.
|
||||
\requires The value type of InputIterator is `RT`.
|
||||
*/
|
||||
template <class InputIterator> Hyperplane_d<Kernel>(int d,
|
||||
InputIterator first, InputIterator last, RT D);
|
||||
|
||||
/*!
|
||||
introduces a variable
|
||||
`h` of type `Hyperplane_d<Kernel>` initialized to the hyperplane
|
||||
with coefficients `set [first,last)`.
|
||||
|
||||
\pre `size [first,last) == d+1`.
|
||||
\requires The value type of InputIterator is `RT`.
|
||||
*/
|
||||
template <class InputIterator> Hyperplane_d<Kernel>(int d,
|
||||
InputIterator first, InputIterator last);
|
||||
|
||||
/*!
|
||||
constructs
|
||||
some hyperplane that passes through the points in `set [first,last)`. If `side` is `ON_POSITIVE_SIDE` or
|
||||
`ON_NEGATIVE_SIDE` then `o` is on that side of the
|
||||
constructed hyperplane.
|
||||
|
||||
\pre A hyperplane with the stated properties must exist.
|
||||
\requires The value type of `ForwardIterator` is `Point_d<Kernel>`.
|
||||
*/
|
||||
template <class ForwardIterator>
|
||||
Hyperplane_d<Kernel>(ForwardIterator first, ForwardIterator last,
|
||||
Point_d<Kernel> o, Oriented_side side = ON_ORIENTED_BOUNDARY);
|
||||
|
||||
/*!
|
||||
constructs the hyperplane with normal direction `dir` that
|
||||
passes through \f$ p\f$. The direction `dir` points into the positive
|
||||
side.
|
||||
|
||||
\pre `p.dimension()==dir.dimension()` and `dir` is not degenerate.
|
||||
*/
|
||||
Hyperplane_d<Kernel>(Point_d<Kernel> p, Direction_d<Kernel>
|
||||
dir);
|
||||
|
||||
/*!
|
||||
introduces a
|
||||
variable `h` of type `Hyperplane_d<Kernel>` in \f$ 2\f$-dimensional
|
||||
space with equation \f$ ax+by+c=0\f$.
|
||||
*/
|
||||
Hyperplane_d<Kernel>(RT a, RT b, RT c);
|
||||
|
||||
/*!
|
||||
introduces a
|
||||
variable `h` of type `Hyperplane_d<Kernel>` in \f$ 3\f$-dimensional
|
||||
space with equation \f$ ax+by+cz+d=0\f$.
|
||||
*/
|
||||
Hyperplane_d<Kernel>(RT a, RT b, RT c, RT d);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the dimension of `h`.
|
||||
*/
|
||||
int dimension() ;
|
||||
|
||||
/*!
|
||||
returns the \f$ i\f$-th coefficient of
|
||||
`h`.
|
||||
|
||||
\pre \f$ 0 \leq i \leq d\f$.
|
||||
*/
|
||||
RT operator[](int i) ;
|
||||
|
||||
/*!
|
||||
returns the \f$ i\f$-th coefficient of
|
||||
`h`.
|
||||
|
||||
\pre \f$ 0 \leq i \leq d\f$.
|
||||
*/
|
||||
RT coefficient(int i) ;
|
||||
|
||||
/*!
|
||||
returns
|
||||
an iterator pointing to the first coefficient.
|
||||
*/
|
||||
Coefficient_const_iterator coefficients_begin() ;
|
||||
|
||||
/*!
|
||||
returns an
|
||||
iterator pointing beyond the last coefficient.
|
||||
*/
|
||||
Coefficient_const_iterator coefficients_end() ;
|
||||
|
||||
/*!
|
||||
returns the orthogonal
|
||||
vector of `h`. It points from the negative halfspace into the
|
||||
positive halfspace and its homogeneous coordinates are \f$ (c_0,
|
||||
\ldots, c_{d - 1},1)\f$.
|
||||
*/
|
||||
Vector_d<Kernel> orthogonal_vector() ;
|
||||
|
||||
/*!
|
||||
returns the
|
||||
orthogonal direction of `h`. It points from the negative
|
||||
halfspace into the positive halfspace.
|
||||
*/
|
||||
Direction_d<Kernel> orthogonal_direction() ;
|
||||
|
||||
/*!
|
||||
returns
|
||||
the side of the hyperplane `h` containing \f$ p\f$.
|
||||
|
||||
\pre `h.dimension() == p.dimension()`.
|
||||
*/
|
||||
Oriented_side oriented_side(const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns true iff point
|
||||
`p` lies on the hyperplane `h`.
|
||||
|
||||
\pre `h.dimension() == p.dimension()`.
|
||||
*/
|
||||
bool has_on(const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns true
|
||||
iff point `p` lies on the boundary of hyperplane `h`.
|
||||
\pre `h.dimension() == p.dimension()`.
|
||||
*/
|
||||
bool has_on_boundary(const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns
|
||||
true iff point `p` lies on the positive side of hyperplane
|
||||
`h`.
|
||||
|
||||
\pre `h.dimension() == p.dimension()`.
|
||||
*/
|
||||
bool has_on_positive_side(const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns
|
||||
true iff point `p` lies on the negative side of hyperplane
|
||||
`h`.
|
||||
|
||||
\pre `h.dimension() == p.dimension()`.
|
||||
*/
|
||||
bool has_on_negative_side(const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns \f$ t(h)\f$.
|
||||
|
||||
\pre `h.dimension() == t.dimension()`.
|
||||
|
||||
*/
|
||||
Hyperplane_d<Kernel> transform(const Aff_transformation_d<Kernel>& t)
|
||||
;
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Hyperplane_d */
|
||||
|
||||
/*!
|
||||
test for weak equality.
|
||||
|
||||
\pre `h1.dimension() == h2.dimension()`.
|
||||
\relates Hyperplane_d
|
||||
*/
|
||||
bool weak_equality(const Hyperplane_d<Kernel>& h1, const Hyperplane_d<Kernel>& h2) ;
|
||||
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelObjs
|
||||
|
||||
An object \f$ b\f$ of the data type `Iso_box_d` is an
|
||||
iso-box in the Euclidean space \f$ \E^d\f$ with edges parallel to the
|
||||
axes of the coordinate system.
|
||||
|
||||
*/
|
||||
template< typename Kernel >
|
||||
class Iso_box_d {
|
||||
public:
|
||||
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
introduces an iso-oriented iso-box `b` with diagonal
|
||||
opposite vertices \f$ p\f$ and \f$ q\f$.
|
||||
|
||||
*/
|
||||
Iso_box_d(const Point_d<Kernel>& p,
|
||||
const Point_d<Kernel> &q);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \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_box_d<Kernel>& b2) const;
|
||||
|
||||
/*!
|
||||
Test for inequality.
|
||||
*/
|
||||
bool operator!=(const Iso_box_d<Kernel>& b2) const;
|
||||
|
||||
/*!
|
||||
returns the smallest vertex of `b`.
|
||||
*/
|
||||
const Point_d<Kernel>& min() const;
|
||||
|
||||
/*!
|
||||
returns the largest vertex of `b`.
|
||||
*/
|
||||
const Point_d<Kernel>& max() const;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Predicates
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
`b` 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_d<Kernel>& p) const;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
bool has_on_boundary(const Point_d<Kernel>& p) const;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
bool has_on_bounded_side(const Point_d<Kernel>& p) const;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
bool has_on_unbounded_side(const Point_d<Kernel>& p) const;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Miscellaneous
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the volume of `b`.
|
||||
*/
|
||||
Kernel_d::FT volume() const;
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Iso_box_d */
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelObjs
|
||||
|
||||
An instance of data type `Line_d` is an oriented line in
|
||||
\f$ d\f$-dimensional Euclidean space.
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
||||
Lines are implemented by a pair of points as an item type. All
|
||||
operations like creation, initialization, tests, direction
|
||||
calculation, input and output on a line \f$ l\f$ take time
|
||||
\f$ O(l.dimension())\f$. `dimension()`, coordinate and point
|
||||
access, and identity test take constant time. The operations for
|
||||
intersection calculation also take time \f$ O(l.dimension())\f$. The
|
||||
space requirement is \f$ O(l.dimension())\f$.
|
||||
|
||||
*/
|
||||
template< typename Kernel >
|
||||
class Line_d {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
the linear algebra layer.
|
||||
|
||||
*/
|
||||
typedef Hidden_type LA;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
introduces a variable `l` of
|
||||
type `Line_d<Kernel>`.
|
||||
*/
|
||||
Line_d<Kernel>();
|
||||
|
||||
/*!
|
||||
introduces a
|
||||
line through `p` and `q` and oriented from `p` to
|
||||
`q`.
|
||||
|
||||
\pre \f$ p\f$ and \f$ q\f$ are distinct and have the same dimension.
|
||||
*/
|
||||
Line_d<Kernel>(Point_d<Kernel> p, Point_d<Kernel> q);
|
||||
|
||||
/*!
|
||||
introduces
|
||||
a line through `p` with direction `dir`.
|
||||
|
||||
\pre `p.dimension()==dir.dimension()`, `dir` is not degenerate.
|
||||
*/
|
||||
Line_d<Kernel>(Point_d<Kernel> p, Direction_d<Kernel> dir);
|
||||
|
||||
/*!
|
||||
introduces a variable
|
||||
`l` of type `Line_d<Kernel>` and initializes it to the line through
|
||||
`s.source()` and `s.target()` with direction from
|
||||
`s.source()` to `s.target()`.
|
||||
|
||||
\pre \f$ s\f$ is not degenerate.
|
||||
*/
|
||||
Line_d<Kernel>(Segment_d<Kernel> s);
|
||||
|
||||
/*!
|
||||
introduces a variable `l` of
|
||||
type `Line_d<Kernel>` and initializes it to the line through
|
||||
`r.point(1)` and `r.point(2)`.
|
||||
*/
|
||||
Line_d<Kernel>(Ray_d<Kernel> r);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the dimension of the ambient
|
||||
space.
|
||||
*/
|
||||
int dimension();
|
||||
|
||||
/*!
|
||||
returns an arbitrary point on
|
||||
`l`. It holds that `point(i) == point(j)`, iff
|
||||
`i==j`. Furthermore, `l` is directed from `point(i)` to
|
||||
`point(j)`, for all `i < j`.
|
||||
*/
|
||||
Point_d<Kernel> point(int i) ;
|
||||
|
||||
/*!
|
||||
returns the line
|
||||
`(point(2),point(1))` of opposite direction.
|
||||
*/
|
||||
Line_d<Kernel> opposite() ;
|
||||
|
||||
/*!
|
||||
returns the direction of
|
||||
`l`.
|
||||
*/
|
||||
Direction_d<Kernel> direction();
|
||||
|
||||
/*!
|
||||
returns \f$ t(l)\f$.
|
||||
|
||||
\pre `l.dimension()==t.dimension()`.
|
||||
*/
|
||||
Line_d<Kernel> transform(const Aff_transformation_d<Kernel> &
|
||||
t);
|
||||
|
||||
/*!
|
||||
returns
|
||||
`l+v`, i.e., `l` translated by vector \f$ v\f$.
|
||||
\pre `l.dimension()==v.dimension()`.
|
||||
*/
|
||||
Line_d<Kernel> operator+(const Vector_d<Kernel>& v);
|
||||
|
||||
/*!
|
||||
returns the
|
||||
point of intersection of `l` with the hyperplane that is
|
||||
orthogonal to `l` and that contains `p`.
|
||||
|
||||
\pre `l.dimension()==p.dimension()`.
|
||||
*/
|
||||
Point_d<Kernel> projection(const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns true if \f$ p\f$ lies
|
||||
on `l` and false otherwise.
|
||||
|
||||
\pre `l.dimension()==p.dimension()`.
|
||||
*/
|
||||
bool has_on(const Point_d<Kernel>& p) ;
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Line_d */
|
||||
|
||||
|
||||
/*!
|
||||
Test for equality as unoriented lines
|
||||
|
||||
\pre `l1.dimension()==l2.dimension()`.
|
||||
\relates Line_d
|
||||
*/
|
||||
bool weak_equality(const Line_d<Kernel>& l1, const Line_d<Kernel>& l2) ;
|
||||
|
||||
/*!
|
||||
returns true if `l1` and `l2` are parallel as unoriented
|
||||
lines and false otherwise.
|
||||
|
||||
\pre `l1.dimension()==l2.dimension()`.
|
||||
\relates Line_d
|
||||
*/
|
||||
bool parallel(const Line_d<Kernel>& l1, const Line_d<Kernel>& l2) ;
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelObjs
|
||||
|
||||
An instance of data type `Point_d<Kernel>` is a point of Euclidean
|
||||
space in dimension \f$ d\f$. A point \f$ p = (p_0,\ldots,p_{ d - 1 })\f$ in
|
||||
\f$ d\f$-dimensional space can be represented by homogeneous coordinates
|
||||
\f$ (h_0,h_1,\ldots,h_d)\f$ of number type `RT` such that \f$ p_i =
|
||||
h_i/h_d\f$, which is of type `FT`. The homogenizing coordinate \f$ h_d\f$
|
||||
is positive.
|
||||
|
||||
We call \f$ p_i\f$, \f$ 0 \leq i < d\f$ the \f$ i\f$-th Cartesian coordinate and
|
||||
\f$ h_i\f$, \f$ 0 \le i \le d\f$, the \f$ i\f$-th homogeneous coordinate. We call \f$ d\f$
|
||||
the dimension of the point.
|
||||
|
||||
Downward compatibility
|
||||
--------------
|
||||
|
||||
We provide operations of the lower
|
||||
dimensional interface `x()`, `y()`, `z()`, `hx()`,
|
||||
`hy()`, `hz()`, `hw()`.
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
||||
Points are implemented by arrays of `RT` items. All operations
|
||||
like creation, initialization, tests, point - vector arithmetic, input
|
||||
and output on a point \f$ p\f$ take time \f$ O(p.dimension())\f$.
|
||||
`dimension()`, coordinate access and conversions take constant
|
||||
time. The space requirement for points is \f$ O(p.dimension())\f$.
|
||||
|
||||
*/
|
||||
template< typename Kernel >
|
||||
class Point_d {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
the linear algebra layer.
|
||||
*/
|
||||
typedef Hidden_type LA;
|
||||
|
||||
/*!
|
||||
a read-only iterator for the
|
||||
Cartesian coordinates.
|
||||
*/
|
||||
typedef Hidden_type Cartesian_const_iterator;
|
||||
|
||||
/*!
|
||||
a read-only iterator for the
|
||||
homogeneous coordinates.
|
||||
*/
|
||||
typedef Hidden_type Homogeneous_const_iterator;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
introduces a variable `p` of
|
||||
type `Point_d<Kernel>`.
|
||||
*/
|
||||
Point_d<Kernel>();
|
||||
|
||||
/*!
|
||||
introduces a variable
|
||||
`p` of type `Point_d<Kernel>` in \f$ d\f$-dimensional space,
|
||||
initialized to the origin.
|
||||
*/
|
||||
Point_d<Kernel>(int d, Origin);
|
||||
|
||||
/*!
|
||||
introduces a variable
|
||||
`p` of type `Point_d<Kernel>` in dimension `d`. If `size [first,last) == d` this creates a point with Cartesian coordinates
|
||||
`set [first,last)`. If `size [first,last) == d+1` the range
|
||||
specifies the homogeneous coordinates
|
||||
\f$ H = set [first,last) = (\pm h_0, \pm h_1, \ldots, \pm h_d)\f$
|
||||
where the sign chosen is the sign of \f$ h_d\f$.
|
||||
|
||||
\pre `d` is nonnegative, `[first,last)` has `d` or `d+1` elements where the last has to be non-zero.
|
||||
\requires The value type of `InputIterator` is `RT`.
|
||||
*/
|
||||
template <class InputIterator> Point_d<Kernel>(int d,
|
||||
InputIterator first, InputIterator last);
|
||||
|
||||
/*!
|
||||
introduces a
|
||||
variable `p` of type `Point_d<Kernel>` in dimension `d`
|
||||
initialized to the point with homogeneous coordinates as defined by
|
||||
`H = set [first,last)` and `D`: \f$ (\pm H[0],
|
||||
\pm H[1], \ldots, \pm H[d-1], \pm D}\f$.
|
||||
The sign chosen is the sign of \f$ D\f$.
|
||||
|
||||
\pre `D` is non-zero, the iterator range defines a \f$ d\f$-tuple of `RT`.
|
||||
\requires The value type of `InputIterator` is `RT`.
|
||||
*/
|
||||
template <class InputIterator> Point_d<Kernel>(int d,
|
||||
InputIterator first, InputIterator last, RT D);
|
||||
|
||||
/*!
|
||||
introduces a variable
|
||||
`p` of type `Point_d<Kernel>` in \f$ 2\f$-dimensional space.
|
||||
\pre \f$ w \neq0\f$.
|
||||
*/
|
||||
Point_d<Kernel>(RT x, RT y, RT w = 1);
|
||||
|
||||
/*!
|
||||
introduces a
|
||||
variable `p` of type `Point_d<Kernel>` in \f$ 3\f$-dimensional
|
||||
space.
|
||||
|
||||
\pre \f$ w \neq0\f$.
|
||||
*/
|
||||
Point_d<Kernel>(RT x, RT y, RT z, RT w);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the dimension of `p`.
|
||||
|
||||
*/
|
||||
int dimension() ;
|
||||
|
||||
/*!
|
||||
returns the \f$ i\f$-th Cartesian
|
||||
coordinate of `p`.
|
||||
|
||||
\pre \f$ 0 \leq i < d\f$.
|
||||
*/
|
||||
FT cartesian(int i) ;
|
||||
|
||||
/*!
|
||||
returns the \f$ i\f$-th Cartesian
|
||||
coordinate of `p`.
|
||||
|
||||
\pre \f$ 0 \leq i < d\f$.
|
||||
*/
|
||||
FT operator[](int i) ;
|
||||
|
||||
/*!
|
||||
returns the \f$ i\f$-th homogeneous
|
||||
coordinate of `p`.
|
||||
|
||||
\pre \f$ 0 \leq i \leq d\f$.
|
||||
*/
|
||||
RT homogeneous(int i) ;
|
||||
|
||||
/*!
|
||||
returns an
|
||||
iterator pointing to the zeroth Cartesian coordinate \f$ p_0\f$ of
|
||||
`p`.
|
||||
*/
|
||||
Cartesian_const_iterator cartesian_begin() ;
|
||||
|
||||
/*!
|
||||
returns an
|
||||
iterator pointing beyond the last Cartesian coordinate of `p`.
|
||||
|
||||
*/
|
||||
Cartesian_const_iterator cartesian_end() ;
|
||||
|
||||
/*!
|
||||
returns
|
||||
an iterator pointing to the zeroth homogeneous coordinate \f$ h_0\f$ of
|
||||
`p`.
|
||||
*/
|
||||
Homogeneous_const_iterator homogeneous_begin() ;
|
||||
|
||||
/*!
|
||||
returns an
|
||||
iterator pointing beyond the last homogeneous coordinate of
|
||||
`p`.
|
||||
*/
|
||||
Homogeneous_const_iterator homogeneous_end() ;
|
||||
|
||||
/*!
|
||||
returns \f$ t(p)\f$.
|
||||
*/
|
||||
Point_d<Kernel> transform(const Aff_transformation_d<Kernel>& t)
|
||||
;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Arithmetic Operators, Tests and IO
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the
|
||||
vector \f$ p-O\f$.
|
||||
*/
|
||||
Vector_d<Kernel> operator-(const Origin& o) ;
|
||||
|
||||
/*!
|
||||
returns \f$ p -
|
||||
q\f$.
|
||||
|
||||
\pre `p.dimension() == q.dimension()`.
|
||||
*/
|
||||
Vector_d<Kernel> operator-(const Point_d<Kernel>& q) ;
|
||||
|
||||
/*!
|
||||
returns \f$ p +
|
||||
v\f$.
|
||||
|
||||
\pre `p.dimension() == v.dimension()`.
|
||||
*/
|
||||
Point_d<Kernel> operator+(const Vector_d<Kernel>& v) ;
|
||||
|
||||
/*!
|
||||
returns \f$ p -
|
||||
v\f$.
|
||||
|
||||
\pre `p.dimension() == v.dimension()`.
|
||||
*/
|
||||
Point_d<Kernel> operator-(const Vector_d<Kernel>& v) ;
|
||||
|
||||
/*!
|
||||
adds `v`
|
||||
to `p`.
|
||||
|
||||
\pre `p.dimension() == v.dimension()`.
|
||||
*/
|
||||
Point_d<Kernel>& operator+=(const Vector_d<Kernel>& v);
|
||||
|
||||
/*!
|
||||
subtracts
|
||||
`v` from `p`.
|
||||
|
||||
\pre `p.dimension() == v.dimension()`.
|
||||
*/
|
||||
Point_d<Kernel>& operator-=(const Vector_d<Kernel>& v);
|
||||
|
||||
/*!
|
||||
returns true if `p` is
|
||||
the origin.
|
||||
*/
|
||||
bool operator==(const Origin&) ;
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Point_d */
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelObjs
|
||||
|
||||
An instance of data type `Ray_d` is a ray in \f$ d\f$-dimensional
|
||||
Euclidean space. It starts in a point called the source of `r` and
|
||||
it goes to infinity.
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
||||
Rays are implemented by a pair of points as an item type. All
|
||||
operations like creation, initialization, tests, direction
|
||||
calculation, input and output on a ray \f$ r\f$ take time
|
||||
\f$ O(r.dimension())\f$. `dimension()`, coordinate and point
|
||||
access, and identity test take constant time. The space requirement is
|
||||
\f$ O(r.dimension())\f$.
|
||||
|
||||
*/
|
||||
template< typename Kernel >
|
||||
class Ray_d {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
the linear algebra layer.
|
||||
|
||||
*/
|
||||
typedef Hidden_type LA;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
introduces some ray in
|
||||
\f$ d\f$-dimensional space.
|
||||
*/
|
||||
Ray_d<Kernel>();
|
||||
|
||||
/*!
|
||||
introduces a ray
|
||||
through `p` and `q` and starting at `p`.
|
||||
|
||||
\pre \f$ p\f$ and \f$ q\f$ are distinct and have the same dimension.
|
||||
|
||||
\pre `p.dimension()==q.dimension()`.
|
||||
*/
|
||||
Ray_d<Kernel>(Point_d<Kernel> p, Point_d<Kernel> q);
|
||||
|
||||
/*!
|
||||
introduces
|
||||
a ray starting in `p` with direction `dir`.
|
||||
|
||||
\pre `p` and `dir` have the same dimension and `dir` is not degenerate.
|
||||
|
||||
\pre `p.dimension()==dir.dimension()`.
|
||||
*/
|
||||
Ray_d<Kernel>(Point_d<Kernel> p, Direction_d<Kernel> dir);
|
||||
|
||||
/*!
|
||||
introduces a ray through
|
||||
`s.source()` and `s.target()` and starting at
|
||||
`s.source()`.
|
||||
|
||||
\pre \f$ s\f$ is not degenerate.
|
||||
*/
|
||||
Ray_d<Kernel>(Segment_d<Kernel> s);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the dimension of the ambient
|
||||
space.
|
||||
*/
|
||||
int dimension() ;
|
||||
|
||||
/*!
|
||||
returns the source point of `r`.
|
||||
|
||||
*/
|
||||
Point_d<Kernel> source() ;
|
||||
|
||||
/*!
|
||||
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_d<Kernel> point(int i) ;
|
||||
|
||||
/*!
|
||||
returns the direction of
|
||||
`r`.
|
||||
*/
|
||||
Direction_d<Kernel> direction() ;
|
||||
|
||||
/*!
|
||||
returns the supporting line
|
||||
of `r`.
|
||||
*/
|
||||
Line_d<Kernel> supporting_line() ;
|
||||
|
||||
/*!
|
||||
returns the ray with direction
|
||||
opposite to `r` and starting in `source`.
|
||||
*/
|
||||
Ray_d<Kernel> opposite() ;
|
||||
|
||||
/*!
|
||||
returns \f$ t(r)\f$.
|
||||
|
||||
\pre `r.dimension()==t.dimension()`.
|
||||
*/
|
||||
Ray_d<Kernel> transform(const Aff_transformation_d<Kernel>& t)
|
||||
;
|
||||
|
||||
/*!
|
||||
returns
|
||||
`r+v`, i.e., `r` translated by vector \f$ v\f$.
|
||||
|
||||
\pre `r.dimension()==v.dimension()`.
|
||||
*/
|
||||
Ray_d<Kernel> operator+(const Vector_d<Kernel>& v) ;
|
||||
|
||||
/*!
|
||||
A point is on `r`,
|
||||
iff it is equal to the source of `r`, or if it is in the interior
|
||||
of `r`.
|
||||
|
||||
\pre `r.dimension()==p.dimension()`.
|
||||
*/
|
||||
bool has_on(const Point_d<Kernel>& p) ;
|
||||
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Ray_d */
|
||||
|
||||
/*!
|
||||
returns true if the unoriented supporting lines of `r1` and
|
||||
`r2` are parallel and false otherwise.
|
||||
|
||||
\pre `r1.dimension()==r2.dimension()`.
|
||||
\relates Ray_d
|
||||
*/
|
||||
bool parallel(const Ray_d<Kernel>& r1, const Ray_d<Kernel>& r2) ;
|
||||
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,219 @@
|
|||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelObjs
|
||||
|
||||
An instance \f$ s\f$ of the data type `Segment_d` is a directed
|
||||
straight line segment in \f$ d\f$-dimensional Euclidean space connecting
|
||||
two points \f$ p\f$ and \f$ q\f$. \f$ p\f$ is called the source point and \f$ q\f$ is
|
||||
called the target point of \f$ s\f$, both points are called endpoints of
|
||||
\f$ s\f$. A segment whose endpoints are equal is called <I>degenerate</I>.
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
||||
Segments are implemented by a pair of points as an item type. All
|
||||
operations like creation, initialization, tests, the calculation of
|
||||
the direction and source - target vector, input and output on a
|
||||
segment \f$ s\f$ take time \f$ O(s.dimension())\f$. `dimension()`,
|
||||
coordinate and end point access, and identity test take constant time.
|
||||
The operations for intersection calculation also take time
|
||||
\f$ O(s.dimension())\f$. The space requirement is
|
||||
\f$ O(s.dimension())\f$.
|
||||
|
||||
*/
|
||||
template< typename Kernel >
|
||||
class Segment_d {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
the linear algebra layer.
|
||||
*/
|
||||
typedef Hidden_type LA;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
introduces a variable `s`
|
||||
of type `Segment_d<Kernel>`.
|
||||
*/
|
||||
Segment_d<Kernel>();
|
||||
|
||||
/*!
|
||||
introduces a
|
||||
variable `s` of type `Segment_d<Kernel>` which is initialized to
|
||||
the segment \f$ (p,q)\f$.
|
||||
|
||||
\pre `p.dimension()==q.dimension()`.
|
||||
*/
|
||||
Segment_d<Kernel>(Point_d<Kernel> p, Point_d<Kernel> q);
|
||||
|
||||
/*!
|
||||
introduces a
|
||||
variable `s` of type `Segment_d<Kernel>` which is initialized to
|
||||
the segment `(p,p+v)`.
|
||||
|
||||
\pre `p.dimension()==v.dimension()`.
|
||||
*/
|
||||
Segment_d<Kernel>(Point_d<Kernel> p, Vector_d<Kernel> v);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the dimension of the ambient
|
||||
space.
|
||||
*/
|
||||
int dimension();
|
||||
|
||||
/*!
|
||||
returns the source point of segment
|
||||
`s`.
|
||||
*/
|
||||
Point_d<Kernel> source();
|
||||
|
||||
/*!
|
||||
returns the target point of segment
|
||||
`s`.
|
||||
*/
|
||||
Point_d<Kernel> target();
|
||||
|
||||
/*!
|
||||
returns source or target of
|
||||
`s`: `vertex(0)` returns the source, `vertex(1)` returns
|
||||
the target. The parameter \f$ i\f$ is taken modulo \f$ 2\f$, which gives easy
|
||||
access to the other vertex.
|
||||
|
||||
\pre \f$ i \geq0\f$.
|
||||
*/
|
||||
Point_d<Kernel> vertex(int i) ;
|
||||
|
||||
/*!
|
||||
returns `vertex(i)`.
|
||||
*/
|
||||
Point_d<Kernel> point(int i) ;
|
||||
|
||||
/*!
|
||||
returns `vertex(i)`.
|
||||
*/
|
||||
Point_d<Kernel> operator[](int i) ;
|
||||
|
||||
/*!
|
||||
returns the lexicographically smaller
|
||||
vertex.
|
||||
*/
|
||||
Point_d<Kernel> min() ;
|
||||
|
||||
/*!
|
||||
returns the lexicographically larger
|
||||
vertex.
|
||||
*/
|
||||
Point_d<Kernel> max() ;
|
||||
|
||||
/*!
|
||||
returns the segment
|
||||
`(target(),source())`.
|
||||
*/
|
||||
Segment_d<Kernel> opposite() ;
|
||||
|
||||
/*!
|
||||
returns the direction from
|
||||
source to target.
|
||||
|
||||
\pre `s` is non-degenerate.
|
||||
*/
|
||||
Direction_d<Kernel> direction() ;
|
||||
|
||||
/*!
|
||||
returns the vector from source to
|
||||
target.
|
||||
*/
|
||||
Vector_d<Kernel> vector() ;
|
||||
|
||||
/*!
|
||||
returns the square of the length of
|
||||
`s`.
|
||||
*/
|
||||
FT squared_length() ;
|
||||
|
||||
/*!
|
||||
returns true if \f$ p\f$ lies
|
||||
on `s` and false otherwise.
|
||||
|
||||
\pre `s.dimension()==p.dimension()`.
|
||||
*/
|
||||
bool has_on(const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns the supporting line
|
||||
of `s`.
|
||||
|
||||
\pre `s` is non-degenerate.
|
||||
*/
|
||||
Line_d<Kernel> supporting_line() ;
|
||||
|
||||
/*!
|
||||
returns \f$ t(s)\f$.
|
||||
|
||||
\pre `s.dimension()==t.dimension()`.
|
||||
*/
|
||||
Segment_d<Kernel> transform(const Aff_transformation_d<Kernel>& t)
|
||||
;
|
||||
|
||||
/*!
|
||||
returns
|
||||
\f$ s+v\f$, i.e., `s` translated by vector \f$ v\f$.
|
||||
|
||||
\pre `s.dimension()==v.dimension()`.
|
||||
*/
|
||||
Segment_d<Kernel> operator+(const Vector_d<Kernel>& v) ;
|
||||
|
||||
/*!
|
||||
returns true if `s` is
|
||||
degenerate i.e. `s.source()=s.target()`.
|
||||
*/
|
||||
bool is_degenerate() ;
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Segment_d */
|
||||
|
||||
/*!
|
||||
Test for equality as unoriented
|
||||
segments.
|
||||
|
||||
\pre `s1.dimension()==s2.dimension()`.
|
||||
\relates Segment_d
|
||||
*/
|
||||
bool weak_equality(const Segment_d<Kernel>& s1, const Segment_d<Kernel>& s2) ;
|
||||
|
||||
/*!
|
||||
return true if one of the segments is degenerate or if the
|
||||
unoriented supporting lines are parallel.
|
||||
|
||||
\pre `s1.dimension()==s2.dimension()`.
|
||||
\relates Segment_d
|
||||
*/
|
||||
bool parallel(const Segment_d<Kernel>& s1, const Segment_d<Kernel>& s2) ;
|
||||
|
||||
|
||||
/*!
|
||||
if `s1` and `s2`
|
||||
touch in a common end point, this point is assigned to `common`
|
||||
and the result is `true`, otherwise the result is `false`. If
|
||||
`s1==s2` then one of the endpoints is returned.
|
||||
|
||||
\pre `s1.dimension()==s2.dimension()`.
|
||||
\relates Segment_d
|
||||
*/
|
||||
bool common_endpoint(const Segment_d<Kernel>& s1, const Segment_d<Kernel>& s2, Point_d<Kernel>& common) ;
|
||||
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,222 @@
|
|||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelObjs
|
||||
|
||||
An instance \f$ S\f$ of the data type `Sphere_d` is an oriented sphere
|
||||
in some \f$ d\f$-dimensional space. A sphere is defined by \f$ d+1\f$ points
|
||||
(class `Point_d<Kernel>`). We use \f$ A\f$ to denote the array of the
|
||||
defining points. A set \f$ A\f$ of defining points is <I>legal</I> if
|
||||
either the points are affinely independent or if the points are all
|
||||
equal. Only a legal set of points defines a sphere in the geometric
|
||||
sense and hence many operations on spheres require the set of defining
|
||||
points to be legal. The orientation of \f$ S\f$ is equal to the
|
||||
orientation of the defining points, i.e., `orientation(A)`.
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
||||
Spheres are implemented by a vector of points as a handle type. All
|
||||
operations like creation, initialization, tests, input and output of a
|
||||
sphere \f$ s\f$ take time \f$ O(s.dimension()) \f$. `dimension()`,
|
||||
point access take constant time. The `center()`-operation takes
|
||||
time \f$ O(d^3)\f$ on its first call and constant time thereafter. The
|
||||
sidedness and orientation tests take time \f$ O(d^3)\f$. The space
|
||||
requirement for spheres is \f$ O(s.dimension())\f$ neglecting the
|
||||
storage room of the points.
|
||||
|
||||
*/
|
||||
template< typename Kernel >
|
||||
class Sphere_d {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
the linear algebra layer.
|
||||
*/
|
||||
typedef Hidden_type LA;
|
||||
|
||||
/*!
|
||||
a read-only iterator for points defining
|
||||
the sphere.
|
||||
*/
|
||||
typedef Hidden_type point_iterator;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
introduces a variable `S`
|
||||
of type `Sphere_d<Kernel>`.
|
||||
*/
|
||||
Sphere_d<Kernel>();
|
||||
|
||||
/*!
|
||||
introduces a variable
|
||||
`S` of type `Sphere_d<Kernel>`. `S` is initialized to the
|
||||
sphere through the points in `A = tuple [first,last)`.
|
||||
|
||||
\pre \f$A\f$ consists of \f$d+1\f$ \f$d\f$-dimensional points.
|
||||
|
||||
\requires The value type of ForwardIterator is `Point_d<Kernel>`.
|
||||
*/
|
||||
template <class ForwardIterator> Sphere_d<Kernel>(int d,
|
||||
ForwardIterator first, ForwardIterator last);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the dimension of the ambient space.
|
||||
*/
|
||||
int dimension();
|
||||
|
||||
/*!
|
||||
returns the \f$ i\f$th defining
|
||||
point.
|
||||
|
||||
\pre \f$ 0 \le i \le dim \f$
|
||||
*/
|
||||
Point_d<Kernel> point(int i) ;
|
||||
|
||||
/*!
|
||||
returns an iterator
|
||||
pointing to the first defining point.
|
||||
*/
|
||||
point_iterator points_begin() ;
|
||||
|
||||
/*!
|
||||
returns an iterator pointing
|
||||
beyond the last defining point.
|
||||
*/
|
||||
point_iterator points_end() ;
|
||||
|
||||
/*!
|
||||
returns true iff the defining points
|
||||
are not full dimensional.
|
||||
*/
|
||||
bool is_degenerate();
|
||||
|
||||
/*!
|
||||
returns true iff the set of defining
|
||||
points is legal. A set of defining points is legal iff their
|
||||
orientation is non-zero or if they are all equal.
|
||||
*/
|
||||
bool is_legal() ;
|
||||
|
||||
/*!
|
||||
returns the center of `S`.
|
||||
\pre `S` is legal.
|
||||
*/
|
||||
Point_d<Kernel> center() ;
|
||||
|
||||
/*!
|
||||
returns the squared radius of the
|
||||
sphere.
|
||||
|
||||
\pre `S` is legal.
|
||||
*/
|
||||
FT squared_radius() ;
|
||||
|
||||
/*!
|
||||
returns the orientation of
|
||||
`S`.
|
||||
*/
|
||||
Orientation orientation() ;
|
||||
|
||||
/*!
|
||||
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 sphere, resp.
|
||||
|
||||
\pre `S.dimension()==p.dimension()`.
|
||||
|
||||
*/
|
||||
Oriented_side oriented_side(const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns
|
||||
`ON_BOUNDED_SIDE`, `ON_BOUNDARY`, or `ON_UNBOUNDED_SIDE`
|
||||
iff p lies properly inside, on the boundary, or properly outside of
|
||||
sphere, resp.
|
||||
|
||||
\pre `S.dimension()==p.dimension()`.
|
||||
*/
|
||||
Bounded_side bounded_side(const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns
|
||||
`S.oriented_side(p)==ON_POSITIVE_SIDE`.
|
||||
|
||||
\pre `S.dimension()==p.dimension()`.
|
||||
*/
|
||||
bool has_on_positive_side (const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns
|
||||
`S.oriented_side(p)==ON_NEGATIVE_SIDE`.
|
||||
|
||||
\pre `S.dimension()==p.dimension()`.
|
||||
*/
|
||||
bool has_on_negative_side (const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns
|
||||
`S.oriented_side(p)==ON_ORIENTED_BOUNDARY`, which is the same as
|
||||
`S.bounded_side(p)==ON_BOUNDARY`.
|
||||
|
||||
\pre `S.dimension()==p.dimension()`.
|
||||
*/
|
||||
bool has_on_boundary (const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns
|
||||
`S.bounded_side(p)==ON_BOUNDED_SIDE`.
|
||||
|
||||
\pre `S.dimension()==p.dimension()`.
|
||||
*/
|
||||
bool has_on_bounded_side (const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns
|
||||
`S.bounded_side(p)==ON_UNBOUNDED_SIDE`.
|
||||
|
||||
\pre `S.dimension()==p.dimension()`.
|
||||
*/
|
||||
bool has_on_unbounded_side (const Point_d<Kernel>& p) ;
|
||||
|
||||
/*!
|
||||
returns the sphere with the same
|
||||
center and squared radius as `S` but with opposite orientation.
|
||||
|
||||
*/
|
||||
Sphere_d<Kernel> opposite() ;
|
||||
|
||||
/*!
|
||||
returns the
|
||||
sphere translated by `v`.
|
||||
|
||||
\pre `S.dimension()==v.dimension()`.
|
||||
*/
|
||||
Sphere_d<Kernel> operator+(const Vector_d<Kernel>& v) ;
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Sphere_d */
|
||||
|
||||
/*!
|
||||
Test for equality as unoriented spheres.
|
||||
\pre `S1.dimension()==S2.dimension()`.
|
||||
\relates Sphere_d
|
||||
*/
|
||||
bool weak_equality(const Sphere_d<Kernel>& S1, const Sphere_d<Kernel>& S2) ;
|
||||
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,311 @@
|
|||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelObjs
|
||||
|
||||
An instance of data type `Vector_d<Kernel>` is a vector of Euclidean
|
||||
space in dimension \f$ d\f$. A vector \f$ r = (r_0,\ldots,r_{ d - 1})\f$ can be
|
||||
represented in homogeneous coordinates \f$ (h_0,\ldots,h_d)\f$ of number
|
||||
type `RT`, such that \f$ r_i = h_i/h_d\f$ which is of type `FT`. We
|
||||
call the \f$ r_i\f$'s the Cartesian coordinates of the vector. The
|
||||
homogenizing coordinate \f$ h_d\f$ is positive.
|
||||
|
||||
This data type is meant for use in computational geometry. It realizes
|
||||
free vectors as opposed to position vectors (type `Point_d`). The
|
||||
main difference between position vectors and free vectors is their
|
||||
behavior under affine transformations, e.g., free vectors are
|
||||
invariant under translations.
|
||||
|
||||
Downward compatibility
|
||||
--------------
|
||||
|
||||
We provide all operations of the
|
||||
lower dimensional interface `x()`, `y()`, `z()`,
|
||||
`hx()`, `hy()`, `hz()`, `hw()`.
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
||||
Vectors are implemented by arrays of variables of type `RT`. All
|
||||
operations like creation, initialization, tests, vector arithmetic,
|
||||
input and output on a vector \f$ v\f$ take time \f$ O(v.dimension())\f$.
|
||||
coordinate access, `dimension()` and conversions take constant
|
||||
time. The space requirement of a vector is \f$ O(v.dimension())\f$.
|
||||
|
||||
*/
|
||||
template< typename Kernel >
|
||||
class Vector_d {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
the linear algebra layer.
|
||||
*/
|
||||
typedef Hidden_type LA;
|
||||
|
||||
/*!
|
||||
a read-only iterator for the
|
||||
Cartesian coordinates.
|
||||
*/
|
||||
typedef Hidden_type Cartesian_const_iterator;
|
||||
|
||||
/*!
|
||||
a read-only iterator for the
|
||||
homogeneous coordinates.
|
||||
*/
|
||||
typedef Hidden_type Homogeneous_const_iterator;
|
||||
|
||||
/*!
|
||||
construction tag.
|
||||
*/
|
||||
typedef Hidden_type Base_vector;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
introduces a variable `v`
|
||||
of type `Vector_d<Kernel>`.
|
||||
*/
|
||||
Vector_d<Kernel>();
|
||||
|
||||
/*!
|
||||
introduces the zero
|
||||
vector `v` of type `Vector_d<Kernel>` in \f$ d\f$-dimensional space.
|
||||
For the creation flag `CGAL::NULL_VECTOR` can be used.
|
||||
*/
|
||||
Vector_d<Kernel>(int d, Null_vector);
|
||||
|
||||
/*!
|
||||
introduces a variable
|
||||
`v` of type `Vector_d<Kernel>` in dimension `d`. If
|
||||
`size [first,last) == d` this creates a vector with Cartesian
|
||||
coordinates `set [first,last)`. If `size [first,last) == p+1` the range specifies the homogeneous coordinates \f$ H = set
|
||||
[first,last) = (\pm h_0, \pm h_1, \ldots, \pm h_d)\f$ where the
|
||||
sign chosen is the sign of \f$ h_d\f$.
|
||||
|
||||
\pre `d` is nonnegative, `[first,last)` has `d` or `d+1` elements where the last has to be non-zero.
|
||||
\requires The value type of `InputIterator` is `RT`.
|
||||
*/
|
||||
template <class InputIterator> Vector_d<Kernel>(int d,
|
||||
InputIterator first, InputIterator last);
|
||||
|
||||
/*!
|
||||
introduces a
|
||||
variable `v` of type `Vector_d<Kernel>` in dimension `d`
|
||||
initialized to the vector with homogeneous coordinates as defined by
|
||||
`H = set [first,last)` and `D`: \f$ (\pmH[0],
|
||||
\pmH[1], \ldots, \pmH[d-1], \pmD)\f$. The sign
|
||||
chosen is the sign of \f$ D\f$.
|
||||
|
||||
\pre `D` is non-zero, the iterator range defines a \f$ d\f$-tuple of `RT`.
|
||||
\requires The value type of `InputIterator` is `RT`.
|
||||
*/
|
||||
template <class InputIterator> Vector_d<Kernel>(int d,
|
||||
InputIterator first, InputIterator last, RT D);
|
||||
|
||||
/*!
|
||||
returns a
|
||||
variable `v` of type `Vector_d<Kernel>` initialized to the \f$ i\f$-th
|
||||
base vector of dimension \f$ d\f$.
|
||||
|
||||
\pre \f$ 0 \leq i < d\f$.
|
||||
*/
|
||||
Vector_d<Kernel>(int d, Base_vector, int i);
|
||||
|
||||
/*!
|
||||
introduces a
|
||||
variable `v` of type `Vector_d<Kernel>` in \f$ 2\f$-dimensional space.
|
||||
\pre \f$ w \neq0\f$.
|
||||
*/
|
||||
Vector_d<Kernel>(RT x, RT y, RT w = 1);
|
||||
|
||||
/*!
|
||||
introduces a
|
||||
variable `v` of type `Vector_d<Kernel>` in \f$ 3\f$-dimensional space.
|
||||
\pre \f$ w \neq0\f$.
|
||||
*/
|
||||
Vector_d<Kernel>(RT x, RT y, RT z, RT w);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the dimension of `v`.
|
||||
*/
|
||||
int dimension() ;
|
||||
|
||||
/*!
|
||||
returns the \f$ i\f$-th Cartesian
|
||||
coordinate of `v`.
|
||||
|
||||
\pre \f$ 0 \leq i < d\f$.
|
||||
*/
|
||||
FT cartesian(int i) ;
|
||||
|
||||
/*!
|
||||
returns the \f$ i\f$-th Cartesian
|
||||
coordinate of `v`.
|
||||
|
||||
\pre \f$ 0 \leq i < d\f$.
|
||||
*/
|
||||
FT operator[](int i) ;
|
||||
|
||||
/*!
|
||||
returns the \f$ i\f$-th homogeneous
|
||||
coordinate of `v`.
|
||||
|
||||
\pre \f$ 0 \leq i \leq d\f$.
|
||||
*/
|
||||
RT homogeneous(int i) ;
|
||||
|
||||
/*!
|
||||
returns the square of the length of
|
||||
`v`.
|
||||
*/
|
||||
FT squared_length() ;
|
||||
|
||||
/*!
|
||||
returns an
|
||||
iterator pointing to the zeroth Cartesian coordinate of `v`.
|
||||
*/
|
||||
Cartesian_const_iterator cartesian_begin() ;
|
||||
|
||||
/*!
|
||||
returns an
|
||||
iterator pointing beyond the last Cartesian coordinate of `v`.
|
||||
|
||||
*/
|
||||
Cartesian_const_iterator cartesian_end() ;
|
||||
|
||||
/*!
|
||||
returns an
|
||||
iterator pointing to the zeroth homogeneous coordinate of `v`.
|
||||
|
||||
*/
|
||||
Homogeneous_const_iterator homogeneous_begin() ;
|
||||
|
||||
/*!
|
||||
returns an
|
||||
iterator pointing beyond the last homogeneous coordinate of `v`.
|
||||
|
||||
*/
|
||||
Homogeneous_const_iterator homogeneous_end() ;
|
||||
|
||||
/*!
|
||||
returns the direction of
|
||||
`v`.
|
||||
*/
|
||||
Direction_d<Kernel> direction() ;
|
||||
|
||||
/*!
|
||||
returns \f$ t(v)\f$.
|
||||
*/
|
||||
Vector_d<Kernel> transform(const Aff_transformation_d<Kernel>& t)
|
||||
;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Arithmetic Operators, Tests and IO
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
multiplies all
|
||||
Cartesian coordinates by `n`.
|
||||
*/
|
||||
Vector_d<Kernel>& operator*=(const RT& n) ;
|
||||
|
||||
/*!
|
||||
multiplies all
|
||||
Cartesian coordinates by `r`.
|
||||
*/
|
||||
Vector_d<Kernel>& operator*=(const FT& r) ;
|
||||
|
||||
/*!
|
||||
returns the vector
|
||||
with Cartesian coordinates \f$ v_i/n, 0 \leq i < d\f$.
|
||||
*/
|
||||
Vector_d<Kernel> operator/(const RT& n) ;
|
||||
|
||||
/*!
|
||||
returns the vector
|
||||
with Cartesian coordinates \f$ v_i/r, 0 \leq i < d\f$.
|
||||
*/
|
||||
Vector_d<Kernel> operator/(const FT& r) ;
|
||||
|
||||
/*!
|
||||
divides all
|
||||
Cartesian coordinates by `n`.
|
||||
*/
|
||||
Vector_d<Kernel>& operator/=(const RT& n) ;
|
||||
|
||||
/*!
|
||||
divides all
|
||||
Cartesian coordinates by `r`.
|
||||
*/
|
||||
Vector_d<Kernel>& operator/=(const FT& r) ;
|
||||
|
||||
/*!
|
||||
inner product, i.e.,
|
||||
\f$ \sum_{ 0 \le i < d } v_i w_i\f$, where \f$ v_i\f$ and \f$ w_i\f$ are the
|
||||
Cartesian coordinates of \f$ v\f$ and \f$ w\f$ respectively.
|
||||
*/
|
||||
FT operator* (const Vector_d<Kernel>& w) ;
|
||||
|
||||
/*!
|
||||
returns the
|
||||
vector with Cartesian coordinates \f$ v_i+w_i, 0 \leq i < d\f$.
|
||||
*/
|
||||
Vector_d<Kernel> operator+(const Vector_d<Kernel>& w) ;
|
||||
|
||||
/*!
|
||||
addition
|
||||
plus assignment.
|
||||
*/
|
||||
Vector_d<Kernel>& operator+=(const Vector_d<Kernel>& w) ;
|
||||
|
||||
/*!
|
||||
returns the
|
||||
vector with Cartesian coordinates \f$ v_i-w_i, 0 \leq i < d\f$.
|
||||
*/
|
||||
Vector_d<Kernel> operator-(const Vector_d<Kernel>& w) ;
|
||||
|
||||
/*!
|
||||
subtraction
|
||||
plus assignment.
|
||||
*/
|
||||
Vector_d<Kernel>& operator-=(const Vector_d<Kernel>& w) ;
|
||||
|
||||
/*!
|
||||
returns the vector in opposite
|
||||
direction.
|
||||
*/
|
||||
Vector_d<Kernel> operator-() ;
|
||||
|
||||
/*!
|
||||
returns true if `v` is the zero
|
||||
vector.
|
||||
*/
|
||||
bool is_zero() ;
|
||||
|
||||
/*!
|
||||
returns the vector with Cartesian coordinates \f$ n v_i\f$.
|
||||
*/
|
||||
Vector_d<Kernel> operator*(const RT& n, const Vector_d<Kernel>& v);
|
||||
|
||||
/*!
|
||||
returns the vector with Cartesian coordinates \f$ r v_i, 0 \leq i <
|
||||
d\f$.
|
||||
*/
|
||||
Vector_d<Kernel> operator*(const FT& r, const Vector_d<Kernel>& v);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Vector_d */
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDLinAlgClasses
|
||||
|
||||
The class `Linear_algebraCd` serves as the default traits class for the LA
|
||||
parameter of `CGAL::Cartesian_d<FT,LA>`. It implements linear
|
||||
algebra for field number types `FT`.
|
||||
|
||||
\models ::LinearAlgebraTraits_d
|
||||
|
||||
Requirements
|
||||
--------------
|
||||
|
||||
`FT` must be a field number type.
|
||||
|
||||
Operations
|
||||
--------------
|
||||
|
||||
Fits all operation requirements of the concept.
|
||||
|
||||
*/
|
||||
template< typename FT >
|
||||
class Linear_algebraCd {
|
||||
public:
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Linear_algebraCd */
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDLinAlgClasses
|
||||
|
||||
The class `Linear_algebraHd` serves as the default traits class for the LA
|
||||
parameter of `CGAL::Homogeneous_d<RT,LA>`. It implements linear
|
||||
algebra for Euclidean ring number types `RT`.
|
||||
|
||||
\models ::LinearAlgebraTraits_d
|
||||
|
||||
Requirements
|
||||
--------------
|
||||
|
||||
To make a ring number type `RT` work with this class it has to
|
||||
provide a division `operator/` with remainder.
|
||||
|
||||
Operations
|
||||
--------------
|
||||
|
||||
Fits all operation requirements of the concept.
|
||||
|
||||
*/
|
||||
template< typename RT >
|
||||
class Linear_algebraHd {
|
||||
public:
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Linear_algebraHd */
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
namespace CGAL {
|
||||
|
||||
/// \addtogroup PkgKernelDFunctions
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
returns the center of the sphere spanned by the points in `A = tuple[first,last)`.
|
||||
|
||||
\pre \f$ A\f$ contains \f$ d+1\f$ affinely independent points of dimension \f$ d\f$.
|
||||
\requires The value type of `ForwardIterator` is `Point_d<R>`.
|
||||
*/
|
||||
template <class ForwardIterator> Point_d<R>
|
||||
center_of_sphere(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
returns the projection of \f$ p = (x_0,\ldots,x_{d-1})\f$ onto the
|
||||
paraboloid of revolution which is the point \f$ (p_0,
|
||||
\ldots,p_{d-1},\sum_{0 \le i < d}p_i^2)\f$ in \f$ (d+1)\f$-space.
|
||||
*/
|
||||
Point_d<R> lift_to_paraboloid(const Point_d<R>& p);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
computes a basis of the linear space
|
||||
spanned by the vectors in `A = tuple [first,last)` and returns
|
||||
it via an iterator range starting in `result`. The returned
|
||||
iterator marks the end of the output.
|
||||
\pre \f$ A\f$ contains vectors of the same dimension \f$ d\f$.
|
||||
|
||||
\requires The value type of `ForwardIterator` and `OutputIterator` is `Vector_d<R>`.
|
||||
*/
|
||||
template <class ForwardIterator, class OutputIterator>
|
||||
OutputIterator linear_base(ForwardIterator first, ForwardIterator
|
||||
last, OutputIterator result);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
computes the midpoint of the segment \f$ pq\f$.
|
||||
|
||||
\pre `p.dimension() == q.dimension()`.
|
||||
*/
|
||||
Point_d<R> midpoint(const Point_d<R>& p, const Point_d<R>&
|
||||
q);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
returns \f$ p\f$ projected along the \f$ d\f$-axis onto the hyperspace spanned
|
||||
by the first \f$ d-1\f$ standard base vectors.
|
||||
*/
|
||||
Point_d<R> project_along_d_axis(const Point_d<R>& p);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
computes the square of the Euclidean distance between the two points
|
||||
\f$ p\f$ and \f$ q\f$.
|
||||
|
||||
\pre The dimensions of \f$ p\f$ and \f$ q\f$ are the same.
|
||||
*/
|
||||
FT squared_distance(Point_d<R> p, Point_d<R> q);
|
||||
|
||||
/// @}
|
||||
|
||||
} /* namespace CGAL */
|
||||
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDFunctions
|
||||
|
||||
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`.
|
||||
|
||||
\pre The objects are of the same dimension.
|
||||
|
||||
The types `Type1` and `Type2` can be any of the following:
|
||||
|
||||
- `Point_d<R>`
|
||||
- `Line_d<R>`
|
||||
- `Ray_d<R>`
|
||||
- `Segment_d<R>`
|
||||
- `Hyperplane_d<R>`
|
||||
|
||||
\sa `intersection`
|
||||
*/
|
||||
bool do_intersect(Type1<R> obj1, Type2<R> obj2);
|
||||
|
||||
/*!
|
||||
\ingroup PkgKernelDFunctions
|
||||
|
||||
returns the intersection result of \f$ f1\f$ and \f$ f2\f$ by means of
|
||||
the polymorphic wrapper type `Object`. The returned object can be
|
||||
tested for the intersection result and assigned by means of the
|
||||
`object_cast` function.
|
||||
|
||||
\pre The objects are of the same dimension.
|
||||
|
||||
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> Type1 </TH>
|
||||
<TH> Type2 </TH>
|
||||
<TH> Return Type </TH>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="CENTER" > Line_d </TD>
|
||||
<TD VALIGN="CENTER" > Line_d </TD>
|
||||
<TD><TABLE>
|
||||
<TR><TD>Point_d</TD></TR>
|
||||
<TR><TD>Line_d</TD></TR>
|
||||
</TABLE></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="CENTER" > Segment_d </TD>
|
||||
<TD VALIGN="CENTER" > Line_d </TD>
|
||||
<TD><TABLE>
|
||||
<TR><TD>Point_d</TD></TR>
|
||||
<TR><TD>Segment_d</TD></TR>
|
||||
</TABLE></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="CENTER" > Segment_d </TD>
|
||||
<TD VALIGN="CENTER" > Segment_d </TD>
|
||||
<TD><TABLE>
|
||||
<TR><TD>Point_d</TD></TR>
|
||||
<TR><TD>Segment_d</TD></TR>
|
||||
</TABLE></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="CENTER" > Ray_d </TD>
|
||||
<TD VALIGN="CENTER" > Line_d </TD>
|
||||
<TD><TABLE>
|
||||
<TR><TD>Point_d</TD></TR>
|
||||
<TR><TD>Ray_d</TD></TR>
|
||||
</TABLE></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="CENTER" > Ray_d </TD>
|
||||
<TD VALIGN="CENTER" > Segment_d </TD>
|
||||
<TD><TABLE>
|
||||
<TR><TD>Point_d</TD></TR>
|
||||
<TR><TD>Segment_d</TD></TR>
|
||||
</TABLE></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="CENTER" > Ray_d </TD>
|
||||
<TD VALIGN="CENTER" > Ray_d </TD>
|
||||
<TD><TABLE>
|
||||
<TR><TD>Point_d</TD></TR>
|
||||
<TR><TD>Segment_d</TD></TR>
|
||||
<TR><TD>Ray_d</TD></TR>
|
||||
</TABLE></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="CENTER" > Hyperplane_d </TD>
|
||||
<TD VALIGN="CENTER" > Line_d </TD>
|
||||
<TD><TABLE>
|
||||
<TR><TD>Point_d</TD></TR>
|
||||
<TR><TD>Line_d</TD></TR>
|
||||
</TABLE></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="CENTER" > Hyperplane_d </TD>
|
||||
<TD VALIGN="CENTER" > Ray_d </TD>
|
||||
<TD><TABLE>
|
||||
<TR><TD>Point_d</TD></TR>
|
||||
<TR><TD>Ray_d</TD></TR>
|
||||
</TABLE></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="CENTER" > Hyperplane_d </TD>
|
||||
<TD VALIGN="CENTER" > Segment_d </TD>
|
||||
<TD><TABLE>
|
||||
<TR><TD>Point_d</TD></TR>
|
||||
<TR><TD>Segment_d</TD></TR>
|
||||
</TABLE></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
Example
|
||||
--------------
|
||||
|
||||
The following example demonstrates the most common use of
|
||||
`intersection` routines.
|
||||
|
||||
\code
|
||||
#include <CGAL/intersections_d.h>
|
||||
|
||||
template <class R>
|
||||
void foo(Segment_d<R> seg, Line_d<R> lin)
|
||||
{
|
||||
Object result = intersection(seg, lin);
|
||||
if (const Point_d<R> *ipnt = object_cast<Point_d<R> >(&result) ) {
|
||||
// handle the point intersection case with *ipnt.
|
||||
} else if (const Segment_d<R> *iseg = object_cast<Segment_d<R> >(&result) ) {
|
||||
// handle the segment intersection case with *iseg.
|
||||
} else {
|
||||
// handle the no intersection case.
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa `do_intersect`, \sa `Kernel_d::Intersect_d`
|
||||
|
||||
*/
|
||||
Object intersection(Type1<R> f1, Type2<R> f2);
|
||||
|
||||
} /* namespace CGAL */
|
||||
|
||||
|
|
@ -0,0 +1,194 @@
|
|||
namespace CGAL {
|
||||
|
||||
/// \addtogroup PkgKernelDFunctions
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
returns true iff the points in `A = tuple [first,last)` are
|
||||
affinely independent.
|
||||
|
||||
\pre The objects are of the same dimension.
|
||||
\requires The value type of `ForwardIterator` is `Point_d<R>`
|
||||
*/
|
||||
template <class ForwardIterator> bool
|
||||
affinely_independent(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
computes
|
||||
the affine rank of the points in `A = tuple [first,last)`.
|
||||
\pre The objects in \f$ A\f$ are of the same dimension.
|
||||
\requires The value type of `ForwardIterator` is `Point_d<R>`.
|
||||
*/
|
||||
template <class ForwardIterator> int
|
||||
affine_rank(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
Compares the Cartesian
|
||||
coordinates of points `p` and `q` lexicographically
|
||||
in ascending order of its Cartesian components `p[i]` and
|
||||
`q[i]` for \f$ i = 0,\ldots,d-1\f$.
|
||||
|
||||
\pre `p.dimension() == q.dimension()`.
|
||||
*/
|
||||
Comparison_result compare_lexicographically(const
|
||||
Point_d<R>& p, const Point_d<R>& q);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
determines whether \f$ p\f$ is contained in
|
||||
the affine hull of the points in `A = tuple [first,last)`.
|
||||
\pre The objects in `A` are of the same dimension.
|
||||
|
||||
\requires The value type of `ForwardIterator` is `Point_d<R>`.
|
||||
*/
|
||||
template <class ForwardIterator> bool
|
||||
contained_in_affine_hull( ForwardIterator first, ForwardIterator
|
||||
last, const Point_d<R>& p);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
determines whether \f$ v\f$ is contained
|
||||
in the linear hull of the vectors in `A = tuple [first,last)`.
|
||||
\pre The objects in \f$ A\f$ are of the same dimension.
|
||||
|
||||
\requires The value type of `ForwardIterator` is `Vector_d<R>`.
|
||||
*/
|
||||
template <class ForwardIterator> bool
|
||||
contained_in_linear_hull( ForwardIterator first, ForwardIterator
|
||||
last, const Vector_d<R>& v);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
determines whether \f$ p\f$ is contained in the
|
||||
simplex of the points in `A = tuple [first,last)`.
|
||||
|
||||
\pre The objects in \f$ A\f$ are of the same dimension and affinely
|
||||
independent.
|
||||
\requires The value type of `ForwardIterator` is `Point_d<R>`.
|
||||
*/
|
||||
template <class ForwardIterator> bool
|
||||
contained_in_simplex( ForwardIterator first, ForwardIterator last,
|
||||
const Point_d<R>& p);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
returns `true` iff `p` is
|
||||
lexicographically smaller than `q` with respect to Cartesian
|
||||
lexicographic order of points.
|
||||
|
||||
\pre `p.dimension() == q.dimension()`.
|
||||
*/
|
||||
bool lexicographically_smaller(const Point_d<R>& p, const
|
||||
Point_d<R>& q);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
returns `true` iff \f$ p\f$ is
|
||||
lexicographically smaller than \f$ q\f$ with respect to Cartesian
|
||||
lexicographic order of points or equal to \f$ q\f$.
|
||||
|
||||
\pre `p.dimension() == q.dimension()`.
|
||||
*/
|
||||
bool lexicographically_smaller_or_equal( const Point_d<R>&
|
||||
p, const Point_d<R>& q);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
decides whether the vectors in `A = tuple [first,last)`
|
||||
are linearly independent.
|
||||
|
||||
\pre The objects in `A` are of the same dimension.
|
||||
\requires The value type of `ForwardIterator` is `Vector_d<R>`.
|
||||
*/
|
||||
template <class ForwardIterator> bool
|
||||
linearly_independent( ForwardIterator first, ForwardIterator
|
||||
last);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
computes
|
||||
the linear rank of the vectors in `A = tuple [first,last)`.
|
||||
\pre The objects are of the same dimension.
|
||||
\requires The value type of `ForwardIterator` is `Vector_d<R>`.
|
||||
*/
|
||||
template <class ForwardIterator> int
|
||||
linear_rank(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
determines the orientation of the points of the tuple `A = tuple [first,last)` where \f$ A\f$ consists of \f$ d+1\f$ points in
|
||||
\f$ d\f$-space. This is the sign of the determinant
|
||||
\f[ \left| \begin{array}{cccc}
|
||||
1 & 1 & 1 & 1 \\
|
||||
A[0] & A[1] & \dots& A[d]
|
||||
\end{array} \right| \f]
|
||||
where `A[i]` denotes the Cartesian coordinate vector of
|
||||
the \f$ i\f$-th point in \f$ A\f$.
|
||||
\pre `size [first,last) == d+1` and `A[i].dimension() == d` \f$ \forall0 \leq i \leq d\f$.
|
||||
|
||||
\requires The value type of `ForwardIterator` is `Point_d<R>`.
|
||||
|
||||
*/
|
||||
template <class ForwardIterator> Orientation
|
||||
orientation(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
returns the relative position of point
|
||||
`p` to the sphere defined by `A = tuple [first,last)`. The
|
||||
order of the points of \f$ A\f$ does not matter.
|
||||
|
||||
\pre `orientation(first,last)` is not `ZERO`.
|
||||
\requires The value type of `ForwardIterator` is `Point_d<R>`.
|
||||
*/
|
||||
template <class ForwardIterator> Bounded_side
|
||||
side_of_bounded_sphere( ForwardIterator first, ForwardIterator last,
|
||||
const Point_d<R>& p);
|
||||
|
||||
/*!
|
||||
|
||||
|
||||
returns the relative position of
|
||||
point `p` to the oriented sphere defined by the points in
|
||||
`A = tuple [first,last)` The order of the points in \f$ A\f$ is
|
||||
important, since it determines the orientation of the implicitly
|
||||
constructed sphere. If the points in \f$ A\f$ are positively oriented,
|
||||
the positive side is the bounded interior of the sphere.
|
||||
|
||||
\pre `A` contains \f$ d+1\f$ points in \f$ d\f$-space.
|
||||
\requires The value type of `ForwardIterator` is `Point_d<R>`.
|
||||
*/
|
||||
template <class ForwardIterator> Oriented_side
|
||||
side_of_oriented_sphere( ForwardIterator first, ForwardIterator
|
||||
last, const Point_d<R>& p);
|
||||
|
||||
/// @}
|
||||
|
||||
} /* namespace CGAL */
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
\authors Michael Seel
|
||||
|
||||
# Linear Algebra Concepts and Classes #
|
||||
# Kernels #
|
||||
# Kernel Objects #
|
||||
# Global Kernel Functions #
|
||||
# Kernel Concept #
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Affine_rank_d {
|
||||
public:
|
||||
|
||||
/// \name Has Models
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
computes
|
||||
the affine rank of the points in `A = tuple [first,last)`.
|
||||
\pre The objects are of the same dimension.
|
||||
|
||||
\requires The value type of `ForwardIterator` is `Kernel_d::Point_d`.
|
||||
*/
|
||||
template <class ForwardIterator> int
|
||||
operator()(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Affine_rank_d */
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Affinely_independent_d {
|
||||
public:
|
||||
|
||||
/// \name Has Models
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns
|
||||
true iff the points in `A = tuple [first,last)` are affinely
|
||||
independent.
|
||||
|
||||
\pre The objects are of the same dimension.
|
||||
|
||||
\requires The value type of `ForwardIterator` is `Kernel_d::Point_d`.
|
||||
*/
|
||||
template <class ForwardIterator> bool
|
||||
operator()(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Affinely_independent_d */
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A type representing an iterator to the Cartesian coordinates of a point
|
||||
in `d` dimensions.
|
||||
|
||||
\refines `CopyConstructible`
|
||||
\refines `Assignable`
|
||||
\refines `DefaultConstructible`
|
||||
|
||||
\models ::BidirectionalIterator
|
||||
|
||||
\sa `Kernel_d::ConstructCartesianConstIterator_d`
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::CartesianConstIterator_d {
|
||||
public:
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::CartesianConstIterator_d */
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Center_of_sphere_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the
|
||||
center of the sphere spanned by the points in `A = tuple [first,last)`.
|
||||
\pre \f$A\f$ contains \f$d+1\f$ affinely independent points of dimension \f$d\f$.
|
||||
\requires The value type of `ForwardIterator` is `Kernel_d::Point_d`.
|
||||
*/
|
||||
template <class ForwardIterator> Kernel_d::Point_d
|
||||
operator()(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Center_of_sphere_d */
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Compare_lexicographically_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Compares the Cartesian coordinates of
|
||||
points `p` and `q` lexicographically in ascending
|
||||
order of its Cartesian components `p[i]` and `q[i]` for \f$ i =
|
||||
0,\ldots,d-1\f$.
|
||||
|
||||
\pre The objects are of the same dimension.
|
||||
*/
|
||||
Comparison_result operator()(const Kernel_d::Point_d&
|
||||
p, const Kernel_d::Point_d& q);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Compare_lexicographically_d */
|
||||
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Component_accessor_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns
|
||||
the dimension of \f$ p\f$.
|
||||
*/
|
||||
int dimension(const Kernel_d::Point_d& p);
|
||||
|
||||
/*!
|
||||
returns the ith homogeneous coordinate of \f$ p\f$.
|
||||
|
||||
\pre `0 <= i <= dimension(p)`.
|
||||
*/
|
||||
Kernel_d::RT homogeneous(const Kernel_d::Point_d& p,
|
||||
int i);
|
||||
|
||||
/*!
|
||||
returns the ith Cartesian coordinate of \f$ p\f$.
|
||||
|
||||
\pre `0 <= i < dimension(p)`.
|
||||
*/
|
||||
Kernel_d::FT cartesian(const Kernel_d::Point_d& p, int
|
||||
i);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Component_accessor_d */
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Compute_coordinate_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the \f$ i\f$th cartesian coordinate of \f$ p\f$
|
||||
*/
|
||||
Kernel_d::FT operator()(const Kernel_d::Point_d&
|
||||
p, int i);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Compute_coordinate_d */
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
\refines `AdaptableFunctor` (with one argument)
|
||||
|
||||
\sa `Kernel_d::CartesianConstIterator_d`
|
||||
|
||||
*/
|
||||
class Kernel_d::ConstructCartesianConstIterator_d {
|
||||
public:
|
||||
/*!
|
||||
returns an iterator on the 0'th Cartesian coordinate of `p`.
|
||||
*/
|
||||
Kernel_d::Cartesian_const_iterator_d operator()(const Kernel_d::Point_d
|
||||
&p);
|
||||
|
||||
/*!
|
||||
returns the past the end iterator of the Cartesian coordinates of `p`.
|
||||
*/
|
||||
Kernel_d::Cartesian_const_iterator_d operator()(const Kernel_d::Point_d
|
||||
&p, int);
|
||||
|
||||
}; /* end Kernel_d::ConstructCartesianConstIterator_d */
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Contained_in_affine_hull_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
determines whether \f$ p\f$ is contained in the
|
||||
affine hull of the points in `A = tuple [first,last)`.
|
||||
\pre The objects are of the same dimension.
|
||||
|
||||
\requires The value type of `ForwardIterator` is `Kernel_d::Point_d`.
|
||||
*/
|
||||
template <class ForwardIterator> Bounded_side
|
||||
operator()( ForwardIterator first, ForwardIterator last, const
|
||||
Kernel_d::Point_d& p);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Contained_in_affine_hull_d */
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Contained_in_linear_hull_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
determines whether \f$ v\f$ is contained in the
|
||||
linear hull of the vectors in `A = tuple [first,last)`.
|
||||
\pre The objects are of the same dimension.
|
||||
\requires The value type of `ForwardIterator` is `Kernel_d::Vector_d`.
|
||||
*/
|
||||
template <class ForwardIterator> Bounded_side
|
||||
operator()( ForwardIterator first, ForwardIterator last, const
|
||||
Kernel_d::Vector_d& v);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Contained_in_linear_hull_d */
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Contained_in_simplex_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
determines whether \f$ p\f$ is contained in the
|
||||
simplex of the points in `A = tuple [first,last)`.
|
||||
|
||||
\pre The objects in \f$ A\f$ are of the same dimension and affinely independent.
|
||||
\requires The value type of `ForwardIterator` is `Kernel_d::Point_d`.
|
||||
*/
|
||||
template <class ForwardIterator> Bounded_side
|
||||
operator()( ForwardIterator first, ForwardIterator last, const
|
||||
Kernel_d::Point_d& p);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Contained_in_simplex_d */
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Equal_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns true iff \f$ p\f$ and \f$ q\f$ are equal (as
|
||||
\f$ d\f$-dimensional points).
|
||||
|
||||
\pre `p` and `q` have the same dimension.
|
||||
*/
|
||||
bool operator()(const Kernel_d::Point_d&p, const
|
||||
Kernel_d::Point_d&q);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Equal_d */
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Has_on_positive_side_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns true iff \f$ p\f$
|
||||
is on the positive side of \f$ o\f$. `Kernel_object` may be any of
|
||||
`Kernel_d::Sphere_d`, `Kernel_d::Hyperplane_d`.\pre `p` and `o` have the same dimension.
|
||||
*/
|
||||
template <class Kernel_object> bool operator()(const
|
||||
Kernel_object& o, const Kernel_d::Point_d& p);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Has_on_positive_side_d */
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Intersect_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the result of the intersection of \f$ p\f$ and \f$ q\f$ in form of a
|
||||
polymorphic object. `Kernel_object` may be any of
|
||||
`Kernel_d::Segment_d`, `Kernel_d::Ray_d`, `Kernel_d::Line_d`,
|
||||
`Kernel_d::Hyperplane_d`.
|
||||
|
||||
\pre `p` and `q` have the same dimension.
|
||||
*/
|
||||
template <class Kernel_object> Object
|
||||
operator()(const Kernel_object& p, const Kernel_object& q);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Intersect_d */
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Less_coordinate_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns `true` iff the \f$ i\f$th Cartesian coordinate
|
||||
of `p` is
|
||||
smaller than the \f$ i\f$th Cartesian coordinate of `q`.
|
||||
|
||||
\pre `p` and `q` have the same dimension.
|
||||
*/
|
||||
bool operator()(const Kernel_d::Point_d&
|
||||
p,const Kernel_d::Point_d&
|
||||
q, int i);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Less_coordinate_d */
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Less_lexicographically_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns `true` iff `p` is
|
||||
lexicographically smaller than `q` with respect to Cartesian
|
||||
lexicographic order of points.
|
||||
|
||||
\pre `p` and `q` have the same dimension.
|
||||
*/
|
||||
bool operator()(const Kernel_d::Point_d&p, const
|
||||
Kernel_d::Point_d&q);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Less_lexicographically_d */
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Less_or_equal_lexicographically_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns `true` iff \f$ p\f$ is
|
||||
lexicographically smaller than \f$ q\f$ with respect to Cartesian
|
||||
lexicographic order of points or equal to \f$ q\f$.
|
||||
|
||||
\pre `p` and `q` have the same dimension.
|
||||
*/
|
||||
bool operator()(const Kernel_d::Point_d& p, const
|
||||
Kernel_d::Point_d& q);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Less_or_equal_lexicographically_d */
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Lift_to_paraboloid_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns \f$ p = (x_0,\ldots,x_{d-1})\f$ lifted to the paraboloid of
|
||||
revolution which is the point \f$ (p_0, \ldots,p_{d-1},\sum_{0 \le i <
|
||||
d}p_i^2)\f$ in \f$ (d+1)\f$-space.
|
||||
*/
|
||||
Kernel_d::Point_d operator()(const Kernel_d::Point_d&
|
||||
p);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Lift_to_paraboloid_d */
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Linear_base_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
computes a basis of the linear space
|
||||
spanned by the vectors in `A = tuple [first,last)` and returns
|
||||
it via an iterator range starting in `result`. The returned
|
||||
iterator marks the end of the output.
|
||||
|
||||
\pre \f$ A\f$ contains vectors of the same dimension \f$ d\f$.
|
||||
\requires The value type of `ForwardIterator` and `OutputIterator` is `Kernel_d::Vector_d`.
|
||||
*/
|
||||
template <class
|
||||
ForwardIterator, class OutputIterator> int
|
||||
operator()(ForwardIterator first, ForwardIterator last,
|
||||
OutputIterator result);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Linear_base_d */
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Linear_rank_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
computes
|
||||
the linear rank of the vectors in `A = tuple [first,last)`.
|
||||
\pre \f$ A\f$ contains vectors of the same dimension \f$ d\f$.
|
||||
|
||||
\requires The value type of `ForwardIterator` is `Kernel_d::Vector_d`.
|
||||
*/
|
||||
template <class ForwardIterator> int
|
||||
operator()(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Linear_rank_d */
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Linearly_independent_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
decides
|
||||
whether the vectors in `A = tuple [first,last)` are linearly
|
||||
independent.
|
||||
|
||||
\pre The objects in `A` are of the same dimension.
|
||||
\requires The value type of `ForwardIterator` is `Kernel_d::Vector_d`.
|
||||
*/
|
||||
template <class ForwardIterator> bool
|
||||
operator()(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Linearly_independent_d */
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Midpoint_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
computes the midpoint of the segment
|
||||
\f$ pq\f$.\pre `p` and `q` have the same dimension.
|
||||
*/
|
||||
Kernel_d::Point_d operator()(const Kernel_d::Point_d&
|
||||
p, const Kernel_d::Point_d& q);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Midpoint_d */
|
||||
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Orientation_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
determines the orientation of the points of the tuple
|
||||
`A = tuple [first,last)` where \f$ A\f$ consists of \f$ d + 1\f$ points in
|
||||
\f$ d\f$-space. This is the sign of the determinant
|
||||
\f[ \left| \begin{array}{cccc}
|
||||
1 & 1 & 1 & 1 \\
|
||||
A[0] & A[1] & \dots& A[d]
|
||||
\end{array} \right| \f]
|
||||
where `A[i]` denotes the Cartesian coordinate vector of
|
||||
the \f$ i\f$-th point in \f$ A\f$.
|
||||
\pre `size [first,last) == d+1` and `A[i].dimension() == d` \f$ \forall0 \leq i \leq d\f$.
|
||||
|
||||
\requires The value type of `ForwardIterator` is `Kernel_d::Point_d`.
|
||||
*/
|
||||
template <class ForwardIterator>
|
||||
Orientation operator()(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Orientation_d */
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Oriented_side_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the side of \f$ p\f$ with respect to \f$ o\f$. `Kernel_object`
|
||||
may be any of `Kernel_d::Sphere_d` or `Kernel_d::Hyperplane_d`.
|
||||
\pre `p` and `o` have the same dimension.
|
||||
*/
|
||||
template <class Kernel_object> Oriented_side
|
||||
operator()(const Kernel_object& o, const Kernel_d::Point_d& p);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Oriented_side_d */
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Orthogonal_vector_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
computes an orthogonal vector to \f$ h\f$.
|
||||
*/
|
||||
Kernel_d::Vector_d operator()(const Kernel_d::Hyperplane_d& h);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Orthogonal_vector_d */
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Point_dimension_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the dimension of \f$ p\f$.
|
||||
*/
|
||||
int operator()(const Kernel_d::Point_d&
|
||||
p);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Point_dimension_d */
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Point_of_sphere_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the ith point defining the sphere \f$ s\f$.
|
||||
*/
|
||||
bool operator()(const Kernel_d::Sphere_d& s, int i);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Point_of_sphere_d */
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Point_to_vector_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
converts \f$ p\f$ to its geometric vector.
|
||||
*/
|
||||
Kernel_d::Vector_d operator()(const Kernel_d::Point_d& p);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Point_to_vector_d */
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Project_along_d_axis_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns \f$ p\f$ projected along the \f$ d\f$-axis onto the hyperspace
|
||||
spanned by the first \f$ d-1\f$ standard base vectors.
|
||||
*/
|
||||
Kernel_d::Point_d operator()(const Kernel_d::Point_d& p);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Project_along_d_axis_d */
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Side_of_bounded_sphere_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the relative position of point
|
||||
`p` to the sphere defined by `A = tuple [first,last)`. The
|
||||
order of the points of \f$ A\f$ does not matter.
|
||||
|
||||
\pre `orientation(first,last)` is not `ZERO`.
|
||||
\requires The value type of `ForwardIterator` is `Kernel_d::Point_d`.
|
||||
*/
|
||||
template <class ForwardIterator> Bounded_side
|
||||
operator()( ForwardIterator first, ForwardIterator last, const
|
||||
Kernel_d::Point_d& p);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Side_of_bounded_sphere_d */
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Side_of_oriented_sphere_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the relative position of point
|
||||
`p` to the oriented sphere defined by the points in `A = tuple [first,last)` The order of the points in \f$ A\f$ is important,
|
||||
since it determines the orientation of the implicitly constructed
|
||||
sphere. If the points in \f$ A\f$ are positively oriented, the positive
|
||||
side is the bounded interior of the sphere.
|
||||
|
||||
\pre `A` contains \f$ d+1\f$ points in \f$ d\f$-space.
|
||||
\requires The value type of `ForwardIterator` is `Kernel_d::Point_d`.
|
||||
*/
|
||||
template <class ForwardIterator> Bounded_side
|
||||
operator()( ForwardIterator first, ForwardIterator last, const
|
||||
Kernel_d::Point_d& p);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Side_of_oriented_sphere_d */
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Squared_distance_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
computes the square of the Euclidean
|
||||
distance between the two points \f$ p\f$ and \f$ q\f$.
|
||||
|
||||
\pre The dimensions of \f$ p\f$ and \f$ q\f$ are the same.
|
||||
*/
|
||||
Kernel_d::FT operator()(const Kernel_d::Point_d& p,
|
||||
const Kernel_d::Point_d& q);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Squared_distance_d */
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Value_at_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
computes the value of \f$ h\f$ evaluated
|
||||
at \f$ p\f$.
|
||||
|
||||
\pre `p` and `h` have the same dimension.
|
||||
*/
|
||||
Kernel_d::FT operator()(const Kernel_d::Hyperplane_d&
|
||||
h, const Kernel_d::Point_d& p);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Value_at_d */
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
A model for this must provide:
|
||||
|
||||
*/
|
||||
|
||||
class Kernel_d::Vector_to_point_d {
|
||||
public:
|
||||
|
||||
/// \name See Also
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
converts \f$ v\f$ to the affine point \f$ 0+v\f$.
|
||||
*/
|
||||
Kernel_d::Point_d operator()(const Kernel_d::Vector_d& v);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d::Vector_to_point_d */
|
||||
|
||||
|
|
@ -0,0 +1,365 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDKernelConcept
|
||||
\cgalconcept
|
||||
|
||||
The concept of a <I>kernel</I> is defined by a set of requirements on
|
||||
the provision of certain types and access member functions to create
|
||||
objects of these types. The types are function object classes to be used
|
||||
within the algorithms and data structures in the basic library of \cgal.
|
||||
This allows you to use any model of a kernel as a traits class in
|
||||
the \cgal algorithms and data structures, unless they require types
|
||||
beyond those provided by a kernel.
|
||||
|
||||
`Kernel_d` subsumes the concept of a <I>\f$ d\f$-dimensional kernel</I>.
|
||||
|
||||
A kernel provides types, construction objects, and generalized
|
||||
predicates. The former replace constructors of the kernel classes and
|
||||
constructive procedures in the kernel. There are also function objects
|
||||
replacing operators, especially for equality testing.
|
||||
|
||||
\hasModel `Cartesian_d<FieldNumberType>`
|
||||
\hasModel `Homogeneous_d<RingNumberType>`
|
||||
*/
|
||||
class Kernel_d {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
a number type that is a model for `FieldNumberType`
|
||||
*/
|
||||
typedef Hidden_type FT;
|
||||
|
||||
/*!
|
||||
a number type that is a model for `RingNumberType`
|
||||
*/
|
||||
typedef Hidden_type RT;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Coordinate Access
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
a type that allows to iterate over
|
||||
the Cartesian coordinates
|
||||
*/
|
||||
typedef Hidden_type Cartesian_const_iterator_d;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Geometric Objects
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Point_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Vector_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Direction_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Hyperplane_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Line_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Ray_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Segment_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Iso_box_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Sphere_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Aff_transformation_d;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Constructions
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Barycentric_coordinates_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Center_of_sphere_d`
|
||||
*/
|
||||
typedef Hidden_type Center_of_sphere_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Compute_coordinate_d`
|
||||
*/
|
||||
typedef Hidden_type Compute_coordinate_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Construct_point_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Construct_vector_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Construct_direction_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Construct_hyperplane_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Construct_segment_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Construct_iso_box_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Construct_line_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Construct_ray_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Construct_sphere_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Construct_aff_transformation_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::ConstructCartesianConstIterator_d`
|
||||
*/
|
||||
typedef Hidden_type Construct_cartesian_const_iterator_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Intersect_d`
|
||||
*/
|
||||
typedef Hidden_type Intersect_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Lift_to_paraboloid_d`
|
||||
*/
|
||||
typedef Hidden_type Lift_to_paraboloid_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Linear_base_d`
|
||||
*/
|
||||
typedef Hidden_type Linear_base_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Midpoint_d`
|
||||
*/
|
||||
typedef Hidden_type Midpoint_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Orthogonal_vector_d`
|
||||
*/
|
||||
typedef Hidden_type Orthogonal_vector_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Point_of_sphere_d`
|
||||
*/
|
||||
typedef Hidden_type Point_of_sphere_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Point_to_vector_d`
|
||||
*/
|
||||
typedef Hidden_type Point_to_vector_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Project_along_d_axis_d`
|
||||
*/
|
||||
typedef Hidden_type Project_along_d_axis_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Squared_distance_d`
|
||||
*/
|
||||
typedef Hidden_type Squared_distance_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Value_at_d`
|
||||
*/
|
||||
typedef Hidden_type Value_at_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Vector_to_point_d`
|
||||
*/
|
||||
typedef Hidden_type Vector_to_point_d;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Generalized Predicates
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Affine_rank_d`
|
||||
*/
|
||||
typedef Hidden_type Affine_rank_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Affinely_independent_d`
|
||||
*/
|
||||
typedef Hidden_type Affinely_independent_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Compare_lexicographically_d`
|
||||
*/
|
||||
typedef Hidden_type Compare_lexicographically_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Component_accessor_d`
|
||||
*/
|
||||
typedef Hidden_type Component_accessor_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Contained_in_affine_hull_d`
|
||||
*/
|
||||
typedef Hidden_type Contained_in_affine_hull_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Contained_in_linear_hull_d`
|
||||
*/
|
||||
typedef Hidden_type Contained_in_linear_hull_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Contained_in_simplex_d`
|
||||
*/
|
||||
typedef Hidden_type Contained_in_simplex_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Equal_d`
|
||||
*/
|
||||
typedef Hidden_type Equal_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Has_on_positive_side_d`
|
||||
*/
|
||||
typedef Hidden_type Has_on_positive_side_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Less_coordinate_d`
|
||||
*/
|
||||
typedef Hidden_type Less_coordinate_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Less_lexicographically_d`
|
||||
*/
|
||||
typedef Hidden_type Less_lexicographically_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Less_or_equal_lexicographically_d`
|
||||
*/
|
||||
typedef Hidden_type Less_or_equal_lexicographically_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Linear_rank_d`
|
||||
*/
|
||||
typedef Hidden_type Linear_rank_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Linearly_independent_d`
|
||||
*/
|
||||
typedef Hidden_type Linearly_independent_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Orientation_d`
|
||||
*/
|
||||
typedef Hidden_type Orientation_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Oriented_side_d`
|
||||
*/
|
||||
typedef Hidden_type Oriented_side_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Point_dimension_d`
|
||||
*/
|
||||
typedef Hidden_type Point_dimension_d;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef Hidden_type Position_on_line_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Side_of_bounded_sphere_d`
|
||||
*/
|
||||
typedef Hidden_type Side_of_bounded_sphere_d;
|
||||
|
||||
/*!
|
||||
a model of `Kernel_d::Side_of_oriented_sphere_d`
|
||||
*/
|
||||
typedef Hidden_type Side_of_oriented_sphere_d;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// The following member functions return function objects of the
|
||||
/// types listed above. The name of the access function is the name of
|
||||
/// the type returned with an `_object` suffix and no capital letter
|
||||
/// at the beginning. We only give two examples to show the
|
||||
/// scheme. For the functors `Construct_point_d` and `Orientation_d`
|
||||
/// the corresponding functions are:
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
Kernel_d::Construct_point_d construct_point_d_object() const;
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
Kernel_d::Orientation_d orientation_d_object() const;
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Kernel_d */
|
||||
|
||||
|
|
@ -0,0 +1,183 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDLinAlgConcepts
|
||||
\cgalconcept
|
||||
|
||||
The data type `LinearAlgebraTraits_d` encapsulates two classes
|
||||
`Matrix`, `Vector` and many functions of basic linear algebra.
|
||||
An instance of data type `Matrix` is a matrix of variables of type
|
||||
`NT`. Accordingly, `Vector` implements vectors of variables of
|
||||
type `NT`. Most functions of linear algebra are <I>checkable</I>,
|
||||
i.e., the programs can be asked for a proof that their output is
|
||||
correct. For example, if the linear system solver declares a linear
|
||||
system \f$ A x = b\f$ unsolvable it also returns a vector \f$ c\f$ such that
|
||||
\f$ c^T A = 0\f$ and \f$ c^T b \neq 0\f$.
|
||||
|
||||
\hasModel `CGAL::Linear_algebraHd<RT>`
|
||||
\hasModel `CGAL::Linear_algebraCd<FT>`
|
||||
|
||||
*/
|
||||
|
||||
class LinearAlgebraTraits_d {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
the number type of the components.
|
||||
*/
|
||||
typedef Hidden_type NT;
|
||||
|
||||
/*!
|
||||
the vector type.
|
||||
*/
|
||||
typedef Hidden_type Vector;
|
||||
|
||||
/*!
|
||||
the matrix type.
|
||||
*/
|
||||
typedef Hidden_type Matrix;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns \f$ M^T\f$
|
||||
(a `M.column_dimension()` \f$ \times\f$ `M.column_dimension()` -
|
||||
matrix).
|
||||
*/
|
||||
static Matrix transpose(const Matrix& M);
|
||||
|
||||
/*!
|
||||
determines whether `M` has an inverse. It also
|
||||
computes either the inverse as \f$ (1/D) \cdot I\f$ or when no
|
||||
inverse exists, a vector \f$ c\f$ such that \f$ c^T \cdot M = 0 \f$.
|
||||
\pre \f$ M\f$ is square.
|
||||
*/
|
||||
static bool inverse(const Matrix& M, Matrix& I, NT& D,
|
||||
Vector& c);
|
||||
|
||||
/*!
|
||||
returns the
|
||||
inverse matrix of `M`. More precisely, \f$ 1/D\f$ times the matrix
|
||||
returned is the inverse of `M`.
|
||||
\pre `determinant(M) != 0`.
|
||||
|
||||
\pre \f$ M\f$ is square.
|
||||
*/
|
||||
static Matrix inverse(const Matrix& M, NT& D) ;
|
||||
|
||||
/*!
|
||||
returns the determinant \f$ D\f$ of
|
||||
`M` and sufficient information to verify that the value of the
|
||||
determinant is correct. If the determinant is zero then \f$ c\f$ is a
|
||||
vector such that \f$ c^T \cdot M = 0\f$. If the determinant is non-zero
|
||||
then \f$ L\f$ and \f$ U\f$ are lower and upper diagonal matrices respectively
|
||||
and \f$ q\f$ encodes a permutation matrix \f$ Q\f$ with \f$ Q(i,j) = 1\f$ iff \f$ i =
|
||||
q(j)\f$ such that \f$ L \cdot M \cdot Q = U\f$, \f$ L(0,0) = 1\f$, \f$ L(i,i) = U(i
|
||||
- 1,i - 1)\f$ for all \f$ i\f$, \f$ 1 \le i < n\f$, and \f$ D = s \cdot U(n - 1,n -
|
||||
1)\f$ where \f$ s\f$ is the determinant of \f$ Q\f$.
|
||||
|
||||
\pre `M` is square.
|
||||
*/
|
||||
static NT determinant (const Matrix& M, Matrix& L, Matrix&
|
||||
U, std::vector<int>& q, Vector& c);
|
||||
|
||||
/*!
|
||||
verifies the conditions stated above.
|
||||
*/
|
||||
static bool verify_determinant (const Matrix& M, NT D,
|
||||
Matrix& L, Matrix& U, const std::vector<int>& q, Vector&
|
||||
c);
|
||||
|
||||
/*!
|
||||
returns the
|
||||
determinant of `M`.
|
||||
|
||||
\pre `M` is square.
|
||||
*/
|
||||
static NT determinant (const Matrix& M);
|
||||
|
||||
/*!
|
||||
returns
|
||||
the sign of the determinant of `M`.
|
||||
|
||||
\pre `M` is square.
|
||||
*/
|
||||
static int sign_of_determinant (const Matrix& M);
|
||||
|
||||
/*!
|
||||
determines
|
||||
the complete solution space of the linear system \f$ M\cdot x = b\f$. If
|
||||
the system is unsolvable then \f$ c^T \cdot M = 0\f$ and \f$ c^T \cdot b
|
||||
\not= 0\f$. If the system is solvable then \f$ (1/D) x\f$ is a solution,
|
||||
and the columns of `spanning_vectors` are a maximal set of
|
||||
linearly independent solutions to the corresponding homogeneous
|
||||
system.
|
||||
|
||||
\pre `M.row_dimension() = b.dimension()`.
|
||||
*/
|
||||
static bool linear_solver(const Matrix& M, const Vector& b,
|
||||
Vector& x, NT& D, Matrix& spanning_vectors, Vector& c);
|
||||
|
||||
/*!
|
||||
determines whether the linear
|
||||
system \f$ M\cdot x = b\f$ is solvable. If yes, then \f$ (1/D) x\f$ is a
|
||||
solution, if not then \f$ c^T \cdot M = 0\f$ and \f$ c^T \cdot b \not= 0\f$.
|
||||
\pre `M.row_dimension() = b.dimension()`.
|
||||
*/
|
||||
static bool linear_solver(const Matrix& M, const Vector& b,
|
||||
Vector& x, NT& D, Vector& c) ;
|
||||
|
||||
/*!
|
||||
as above, but without the witness \f$ c\f$
|
||||
\pre `M.row_dimension() = b.dimension()`.
|
||||
*/
|
||||
static bool linear_solver(const Matrix& M, const Vector& b,
|
||||
Vector& x, NT& D) ;
|
||||
|
||||
/*!
|
||||
determines whether the system \f$ M \cdot x = b\f$ is solvable
|
||||
|
||||
\pre `M.row_dimension() = b.dimension()`.
|
||||
*/
|
||||
static bool is_solvable(const Matrix& M, const Vector& b)
|
||||
;
|
||||
|
||||
/*!
|
||||
determines whether the homogeneous linear system
|
||||
\f$ M\cdot x = 0\f$ has a non - trivial solution. If yes, then \f$ x\f$ is
|
||||
such a solution.
|
||||
*/
|
||||
static bool homogeneous_linear_solver (const Matrix& M,
|
||||
Vector& x);
|
||||
|
||||
/*!
|
||||
determines the solution space of the
|
||||
homogeneous linear system \f$ M\cdot x = 0\f$. It returns the dimension
|
||||
of the solution space. Moreover the columns of `spanning_vecs`
|
||||
span the solution space.
|
||||
*/
|
||||
static int homogeneous_linear_solver (const Matrix& M,
|
||||
Matrix& spanning_vecs);
|
||||
|
||||
/*!
|
||||
returns the indices of a maximal subset
|
||||
of independent columns of `M`.
|
||||
*/
|
||||
static int independent_columns (const Matrix& M,
|
||||
std::vector<int>& columns);
|
||||
|
||||
/*!
|
||||
returns the rank of
|
||||
matrix `M`
|
||||
*/
|
||||
static int rank (const Matrix & M);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end LinearAlgebraTraits_d */
|
||||
|
||||
|
|
@ -0,0 +1,354 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDLinAlgConcepts
|
||||
\cgalconcept
|
||||
|
||||
An instance of data type `Matrix` is a matrix of
|
||||
variables of number type `NT`. The types `Matrix` and `Vector`
|
||||
together realize many functions of basic linear algebra.
|
||||
|
||||
*/
|
||||
|
||||
class Matrix {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
the ring type of the components.
|
||||
*/
|
||||
typedef Hidden_type NT;
|
||||
|
||||
/*!
|
||||
bidirectional iterator for accessing
|
||||
all components row-wise.
|
||||
*/
|
||||
typedef Hidden_type iterator;
|
||||
|
||||
/*!
|
||||
bidirectional iterator for accessing
|
||||
all components row-wise.
|
||||
*/
|
||||
typedef Hidden_type const_iterator;
|
||||
|
||||
|
||||
/*!
|
||||
random access iterator for accessing row
|
||||
entries.
|
||||
*/
|
||||
typedef Hidden_type row_iterator;
|
||||
|
||||
/*!
|
||||
random access iterator for accessing row
|
||||
entries.
|
||||
*/
|
||||
typedef Hidden_type const_row_iterator;
|
||||
|
||||
/*!
|
||||
random access iterator for accessing
|
||||
column entries.
|
||||
*/
|
||||
typedef Hidden_type column_iterator;
|
||||
|
||||
/*!
|
||||
random access iterator for accessing
|
||||
column entries.
|
||||
*/
|
||||
typedef Hidden_type const_column_iterator;
|
||||
|
||||
/*!
|
||||
a tag class for identity initialization
|
||||
*/
|
||||
typedef Hidden_type Identity;
|
||||
|
||||
/*!
|
||||
the vector type used.
|
||||
*/
|
||||
typedef Hidden_type Vector;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
creates an instance `M` of type
|
||||
`Matrix`.
|
||||
*/
|
||||
Matrix();
|
||||
|
||||
/*!
|
||||
creates an instance `M` of type
|
||||
`Matrix` of dimension \f$ n \times n\f$ initialized to the zero matrix.
|
||||
|
||||
*/
|
||||
Matrix(int n);
|
||||
|
||||
/*!
|
||||
creates an instance `M` of
|
||||
type `Matrix` of dimension \f$ m \times n\f$ initialized to the zero
|
||||
matrix.
|
||||
*/
|
||||
Matrix(int m, int n);
|
||||
|
||||
/*!
|
||||
creates an instance
|
||||
`M` of type `Matrix` of dimension
|
||||
`p.first`\f$ \times\f$`p.second` initialized to the zero matrix.
|
||||
*/
|
||||
Matrix(std::pair<int,int> p);
|
||||
|
||||
/*!
|
||||
creates an
|
||||
instance `M` of type `Matrix` of dimension \f$ n \times n\f$
|
||||
initialized to the identity matrix (times `x`).
|
||||
*/
|
||||
Matrix(int n, Identity, NT x = NT(1));
|
||||
|
||||
/*!
|
||||
creates an instance `M`
|
||||
of type `Matrix` of dimension \f$ m \times n\f$ initialized to the
|
||||
matrix with `x` entries.
|
||||
*/
|
||||
Matrix(int m, int n, NT x);
|
||||
|
||||
/*!
|
||||
creates an
|
||||
instance `M` of type `Matrix`. Let \f$ S\f$ be the ordered set of
|
||||
\f$ n\f$ column-vectors of common dimension \f$ m\f$ as given by the iterator
|
||||
range `[first,last)`. `M` is initialized to an \f$ m \times n\f$
|
||||
matrix with the columns as specified by \f$ S\f$.
|
||||
|
||||
\pre `Forward_iterator` has a value type `V` from which we require to provide a iterator type `V::const_iterator`, to have `V::value_type == NT`.
|
||||
|
||||
Note that `Vector` or `std::vector<NT>` fulfill these requirements.
|
||||
*/
|
||||
template <class Forward_iterator>
|
||||
Matrix(Forward_iterator first, Forward_iterator last);
|
||||
|
||||
/*!
|
||||
creates an instance
|
||||
`M` of type `Matrix`. Let \f$ A\f$ be an array of \f$ n\f$
|
||||
column-vectors of common dimension \f$ m\f$. `M` is initialized to an
|
||||
\f$ m \times n\f$ matrix with the columns as specified by \f$ A\f$.
|
||||
*/
|
||||
Matrix(std::vector< Vector > A);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns \f$ n\f$, the number of rows of
|
||||
`M`.
|
||||
*/
|
||||
int row_dimension() ;
|
||||
|
||||
/*!
|
||||
returns \f$ m\f$, the number of columns
|
||||
of `M`.
|
||||
*/
|
||||
int column_dimension() ;
|
||||
|
||||
/*!
|
||||
returns \f$ (m,n)\f$, the
|
||||
dimension pair of `M`.
|
||||
*/
|
||||
std::pair<int,int> dimension() ;
|
||||
|
||||
/*!
|
||||
returns the \f$ i\f$-th row of `M` (an
|
||||
\f$ m\f$ - vector).
|
||||
|
||||
\pre \f$ 0 \le i \le m - 1\f$.
|
||||
*/
|
||||
Vector row(int i) ;
|
||||
|
||||
/*!
|
||||
returns the \f$ i\f$-th column of `M`
|
||||
(an \f$ n\f$ - vector).
|
||||
|
||||
\pre \f$ 0 \le i \le n - 1\f$.
|
||||
*/
|
||||
Vector column(int i) ;
|
||||
|
||||
/*!
|
||||
returns \f$ M_{i,j}\f$.
|
||||
\pre \f$ 0\le i\le m-1\f$ and \f$ 0\le j\le n-1\f$.
|
||||
*/
|
||||
NT& operator()(int i, int j) ;
|
||||
|
||||
/*!
|
||||
swaps rows \f$ i\f$ and \f$ j\f$.
|
||||
\pre \f$ 0\le i\le m-1\f$ and \f$ 0\le j\le m-1\f$.
|
||||
|
||||
*/
|
||||
void swap_rows(int i, int j) ;
|
||||
|
||||
/*!
|
||||
swaps columns \f$ i\f$ and
|
||||
\f$ j\f$.
|
||||
|
||||
\pre \f$ 0\le i\le n-1\f$ and \f$ 0\le j\le n-1\f$.
|
||||
*/
|
||||
void swap_columns(int i, int j) ;
|
||||
|
||||
/*!
|
||||
an iterator pointing to the
|
||||
first entry of the \f$ i\f$th row.
|
||||
|
||||
\pre \f$ 0\le i\le m-1\f$.
|
||||
*/
|
||||
row_iterator row_begin(int i) ;
|
||||
|
||||
/*!
|
||||
an iterator pointing beyond
|
||||
the last entry of the \f$ i\f$th row.
|
||||
|
||||
\pre \f$ 0\le i\le m-1\f$.
|
||||
*/
|
||||
row_iterator row_end(int i) ;
|
||||
|
||||
/*!
|
||||
an iterator pointing to the
|
||||
first entry of the \f$ i\f$th row.
|
||||
|
||||
\pre \f$ 0\le i\le m-1\f$.
|
||||
*/
|
||||
const_row_iterator row_begin(int i) const;
|
||||
|
||||
/*!
|
||||
an iterator pointing beyond
|
||||
the last entry of the \f$ i\f$th row.
|
||||
|
||||
\pre \f$ 0\le i\le m-1\f$.
|
||||
*/
|
||||
const_row_iterator row_end(int i) const;
|
||||
|
||||
/*!
|
||||
an iterator pointing
|
||||
to the first entry of the \f$ i\f$th column.
|
||||
|
||||
\pre \f$ 0\le i\le n-1\f$.
|
||||
|
||||
*/
|
||||
column_iterator column_begin(int i) ;
|
||||
|
||||
/*!
|
||||
an iterator pointing
|
||||
beyond the last entry of the \f$ i\f$th column.
|
||||
|
||||
\pre \f$ 0\le i\le n-1\f$.
|
||||
*/
|
||||
column_iterator column_end(int i) ;
|
||||
|
||||
/*!
|
||||
an iterator pointing
|
||||
to the first entry of the \f$ i\f$th column.
|
||||
|
||||
\pre \f$ 0\le i\le n-1\f$.
|
||||
|
||||
*/
|
||||
const_column_iterator column_begin(int i) const;
|
||||
|
||||
/*!
|
||||
an iterator pointing
|
||||
beyond the last entry of the \f$ i\f$th column.
|
||||
|
||||
\pre \f$ 0\le i\le n-1\f$.
|
||||
*/
|
||||
const_column_iterator column_end(int i) const;
|
||||
|
||||
|
||||
/*!
|
||||
an iterator pointing to the first entry
|
||||
of \f$ M\f$.
|
||||
*/
|
||||
iterator begin();
|
||||
|
||||
/*!
|
||||
an iterator pointing beyond the last entry
|
||||
of \f$ M\f$.
|
||||
*/
|
||||
terator end();
|
||||
|
||||
/*!
|
||||
an iterator pointing to the first entry
|
||||
of \f$ M\f$.
|
||||
*/
|
||||
const_iterator begin() const;
|
||||
|
||||
/*!
|
||||
an iterator pointing beyond the last entry
|
||||
of \f$ M\f$.
|
||||
*/
|
||||
const_terator end() const;
|
||||
|
||||
|
||||
/*!
|
||||
Test for equality.
|
||||
*/
|
||||
bool operator==(const Matrix& M1) ;
|
||||
|
||||
/*!
|
||||
Test for inequality.
|
||||
*/
|
||||
bool operator!=(const Matrix& M1) ;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Arithmetic Operators
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Addition.
|
||||
\pre `M.row_dimension() == M1.row_dimension()`
|
||||
\pre `M.column_dimension() == M1.column_dimension()`
|
||||
*/
|
||||
Matrix operator+ (const Matrix& M1);
|
||||
|
||||
/*!
|
||||
|
||||
Subtraction.
|
||||
\pre `M.row_dimension() == M1.row_dimension()`
|
||||
\pre `M.column_dimension() == M1.column_dimension()`
|
||||
*/
|
||||
Matrix operator- (const Matrix& M1);
|
||||
|
||||
/*!
|
||||
Negation.
|
||||
*/
|
||||
Matrix operator-();
|
||||
|
||||
/*!
|
||||
Multiplication.
|
||||
|
||||
\pre `M.column_dimension() = M1.row_dimension()`
|
||||
*/
|
||||
Matrix operator*(const Matrix& M1)
|
||||
;
|
||||
|
||||
/*!
|
||||
Multiplication with
|
||||
vector.
|
||||
|
||||
\pre `M.column_dimension() = vec.dimension()`
|
||||
*/
|
||||
Vector operator*(const Vector& vec) ;
|
||||
|
||||
/*!
|
||||
Multiplication of every entry with `x`.
|
||||
*/
|
||||
Matrix operator*(const NT& x, const Matrix& M);
|
||||
|
||||
/*!
|
||||
Multiplication of every entry with `x`.
|
||||
*/
|
||||
Matrix operator*(const Matrix& M, const NT& x) ;
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Matrix */
|
||||
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
|
||||
/*!
|
||||
\ingroup PkgKernelDLinAlgConcepts
|
||||
\cgalconcept
|
||||
|
||||
An instance of data type `Vector` is a vector of variables of
|
||||
number type `NT`. Together with the type `Matrix` it realizes
|
||||
the basic operations of linear algebra.
|
||||
|
||||
Operations
|
||||
--------------
|
||||
|
||||
The same operations `begin()`, `end()` exist for
|
||||
`const_iterator`.
|
||||
|
||||
*/
|
||||
|
||||
class Vector {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
the ring type of the components.
|
||||
*/
|
||||
typedef Hidden_type NT;
|
||||
|
||||
/*!
|
||||
the iterator type for accessing components.
|
||||
*/
|
||||
typedef Hidden_type iterator;
|
||||
|
||||
/*!
|
||||
the const iterator type for accessing
|
||||
components.
|
||||
*/
|
||||
typedef Hidden_type const_iterator;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
creates an instance `v` of type
|
||||
`Vector`.
|
||||
*/
|
||||
Vector();
|
||||
|
||||
/*!
|
||||
creates an instance `v` of type
|
||||
`Vector`. `v` is initialized to a vector of dimension \f$ d\f$.
|
||||
|
||||
*/
|
||||
Vector(int d);
|
||||
|
||||
/*!
|
||||
creates an instance `v` of
|
||||
type `Vector`. `v` is initialized to a vector of dimension
|
||||
\f$ d\f$ with entries `x`.
|
||||
*/
|
||||
Vector(int d, NT x);
|
||||
|
||||
/*!
|
||||
creates an
|
||||
instance `v` of type `Vector`; `v` is initialized to the
|
||||
vector with entries `set [first,last)`.
|
||||
\requires `Forward_iterator` has value type `NT`.
|
||||
*/
|
||||
template <class Forward_iterator>
|
||||
Vector(Forward_iterator first, Forward_iterator last);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
returns the dimension of `v`.
|
||||
*/
|
||||
int dimension() ;
|
||||
|
||||
/*!
|
||||
returns true iff `v` is the zero
|
||||
vector.
|
||||
*/
|
||||
bool is_zero() ;
|
||||
|
||||
/*!
|
||||
returns the \f$ i\f$-th component of `v`.
|
||||
|
||||
\pre \f$ 0\le i \le v.dimension()-1\f$.
|
||||
*/
|
||||
NT& operator[](int i) ;
|
||||
|
||||
/*!
|
||||
iterator to the first component.
|
||||
*/
|
||||
iterator begin() ;
|
||||
|
||||
/*!
|
||||
iterator beyond the last component.
|
||||
*/
|
||||
iterator end() ;
|
||||
|
||||
/*!
|
||||
Addition.
|
||||
|
||||
\pre `v.dimension() == v1.dimension()`.
|
||||
*/
|
||||
Vector operator+(const Vector& v1) ;
|
||||
|
||||
/*!
|
||||
Subtraction.
|
||||
|
||||
\pre `v.dimension() = v1.dimension()`.
|
||||
*/
|
||||
Vector operator-(const Vector& v1) ;
|
||||
|
||||
/*!
|
||||
Inner Product.
|
||||
|
||||
\pre `v.dimension() = v1.dimension()`.
|
||||
*/
|
||||
NT operator*(const Vector& v1) ;
|
||||
|
||||
/*!
|
||||
Negation.
|
||||
*/
|
||||
Vector operator-() ;
|
||||
|
||||
/*!
|
||||
Addition plus assignment.
|
||||
|
||||
\pre `v.dimension() == v1.dimension()`.
|
||||
*/
|
||||
Vector& operator+=(const Vector& v1);
|
||||
|
||||
/*!
|
||||
Subtraction plus assignment.
|
||||
|
||||
\pre `v.dimension() == v1.dimension()`.
|
||||
*/
|
||||
Vector& operator-=(const Vector& v1);
|
||||
|
||||
/*!
|
||||
Scalar multiplication plus
|
||||
assignment.
|
||||
*/
|
||||
Vector& operator*=(const NT& s);
|
||||
|
||||
/*!
|
||||
Scalar division plus assignment.
|
||||
|
||||
*/
|
||||
Vector& operator/=(const NT& s);
|
||||
|
||||
/*!
|
||||
Component-wise multiplication with number \f$ r\f$.
|
||||
*/
|
||||
Vector operator*(const NT& r, const Vector& v);
|
||||
|
||||
/*!
|
||||
Component-wise multiplication with number \f$ r\f$.
|
||||
*/
|
||||
Vector operator*(const Vector& v, const NT& r);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Vector */
|
||||
|
||||
|
|
@ -0,0 +1,516 @@
|
|||
namespace CGAL {
|
||||
/*!
|
||||
|
||||
\mainpage dD Geometry Kernel
|
||||
\autotoc
|
||||
\authors Michael Seel
|
||||
|
||||
# Introduction #
|
||||
|
||||
This part of the reference manual covers the higher-dimensional
|
||||
kernel. The kernel contains objects of constant size, such as point,
|
||||
vector, direction, line, ray, segment, circle. 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. Note that this section
|
||||
partly recapitulates facts already mentioned for the lower-dimensional
|
||||
kernel.
|
||||
|
||||
## 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 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é \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.
|
||||
|
||||
## Genericity ##
|
||||
|
||||
To increase generic usage of objects and predicates the
|
||||
higher-dimensional kernel makes heavy use of iterator ranges as
|
||||
defined in the STL for modeling tuples. Iterators conceptualize C++
|
||||
pointers.
|
||||
|
||||
For an iterator range `[first,last)` we define `T = tuple [first,last)` as the ordered tuple \f$ (T[0],T[1], \ldots T[d-1])\f$
|
||||
where \f$ S[i] = *++^{(i)}\mathit{first}\f$ (the element obtained by \f$ i\f$
|
||||
times forwarding the iterator by operator `++` and then
|
||||
dereferencing it to get the value to which it points). We write `d = size [first,last)` and `S = set [first,last)` to denote the
|
||||
unordered set of elements of the corresponding tuple.
|
||||
|
||||
This extends the syntax of random access iterators to input iterators.
|
||||
If we index the tuple as above then we require that
|
||||
\f$ ++^{(d+1)}\mathit{first} = \mathit{last}\f$.
|
||||
|
||||
# Kernel Representations #
|
||||
|
||||
Our object of study is the \f$ d\f$-dimensional affine Euclidean space,
|
||||
where \f$ d\f$ is a parameter of our geometry. 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. In \cgal such a kernel concept is often also called a
|
||||
<I>representation class</I> and denoted by `R`. A representation
|
||||
class provides the actual implementations of the kernel objects. For
|
||||
all kernel objects `Kernel_object`, the types
|
||||
`CGAL::Kernel_object<R>` and `R::Kernel_object` are identical.
|
||||
|
||||
\cgal offers two families of concrete models for the concept
|
||||
representation class, one based on the Cartesian
|
||||
representation of points and one 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 have a constructor with a range of coordinates plus a
|
||||
common denominator (the \f$ d+1\f$ homogeneous coordinates of the point).
|
||||
The common interfaces parameterized with a representation 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
|
||||
and the linear algebra module used to calculate the result of
|
||||
predicates and constructions.
|
||||
|
||||
For reasons that will become evident later, a representation class
|
||||
provides two typenames for number types,
|
||||
namely `R::FT` and `R::RT` and one typename for the linear
|
||||
algebra module `R::LA`.
|
||||
The type `R::FT` must fulfill the
|
||||
requirements on what is called a <I>field type</I> in \cgal. This
|
||||
roughly means that `R::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 `R::RT` are
|
||||
weaker. This type must fulfill the requirements on what is called an
|
||||
<I>Euclidean ring type</I> in \cgal. This roughly means that
|
||||
`R::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. A very limited division operation \f$ /\f$
|
||||
must be available as well. It must work for exact (i.e., no
|
||||
remainder) integer divisions only. Furthermore, both number types
|
||||
should fulfill \cgal's requirements on a number type.
|
||||
|
||||
## Cartesian Kernel ##
|
||||
|
||||
With `Cartesian_d<FieldNumberType,LinearAlgebra>` you can choose
|
||||
Cartesian representation of coordinates. The type
|
||||
`LinearAlgebra` must me a linear algebra module working on numbers
|
||||
of type `FieldNumberType`. The second parameter defaults to module
|
||||
delivered with the kernel so for short a user can just write
|
||||
`Cartesian_d<FieldNumberType>` when not providing her own linear
|
||||
algebra.
|
||||
|
||||
When you choose Cartesian representation you have
|
||||
to declare at least the type of the coordinates. A number type used
|
||||
with the `Cartesian_d` representation class should be a <I>field
|
||||
type</I> as described above. Both `Cartesian<FieldNumberType>::FT`
|
||||
and `Cartesian<FieldNumberType>::RT` are mapped to number type
|
||||
`FieldNumberType`.
|
||||
`Cartesian_d<FieldNumberType,LinearAlgebra>::LA` is mapped to the
|
||||
type `LinearAlgebra`. `Cartesian<FieldNumberType>` uses
|
||||
reference counting internally to save copying costs.
|
||||
|
||||
## Homogeneous Kernel ##
|
||||
|
||||
As we mentioned before, 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_d<RingNumberType,LinearAlgebra>` you can choose
|
||||
homogeneous representation of coordinates with the kernel objects.
|
||||
As for Cartesian representation you have to declare
|
||||
at the same time the type used to store the homogeneous coordinates.
|
||||
Since the homogeneous representation allows one to avoid the
|
||||
divisions, the number type associated with a homogeneous
|
||||
representation class must be a model for the weaker concept Euclidean
|
||||
ring type only.
|
||||
|
||||
The type `LinearAlgebra` must me a linear algebra module working
|
||||
on numbers of type `RingNumberType`. Again the second parameter
|
||||
defaults to module delivered with the kernel so for short one can just
|
||||
write `Homogeneous_d<RingNumberType>` when replacing the default
|
||||
is no issue.
|
||||
|
||||
However, some operations provided by this kernel involve division
|
||||
operations, for example computing squared distances or returning a
|
||||
Cartesian coordinate. To keep the requirements on
|
||||
the number type parameter of `Homogeneous` low, the number type
|
||||
`Quotient<RingNumberType>` is used instead. This number type
|
||||
turns a ring type into a field type. It maintains numbers as
|
||||
quotients, i.e. a numerator and a denominator. Thereby, divisions are
|
||||
circumvented. With `Homogeneous_d<RingNumberType>`,
|
||||
`Homogeneous_d<RingNumberType>::FT` is equal to
|
||||
`Quotient<RingNumberType>` while
|
||||
`Homogeneous_d<RingNumberType>::RT` is equal to
|
||||
`RingNumberType`.
|
||||
`Homogeneous_d<RingNumberType,LinearAlgebra>::LA` is mapped to the
|
||||
type `LinearAlgebra`.
|
||||
|
||||
## Naming conventions ##
|
||||
|
||||
The use of representation 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`, `Triangle`.
|
||||
|
||||
<LI>Followed by `_d`.
|
||||
|
||||
<LI>A <I>representation class</I> as parameter, which itself is
|
||||
parameterized with a number type, such as
|
||||
`Cartesian_d<double>` or `Homogeneous_d<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 a kernel. In these cases, a kernel can
|
||||
not be used as a traits class.
|
||||
|
||||
## Choosing a Kernel ##
|
||||
|
||||
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.
|
||||
|
||||
The dimension \f$ d\f$ of our affine space determines the dimension of the
|
||||
matrix computations in the mathematical evaluation of predicates. As
|
||||
rounding errors accumulate fast the homogeneous representation used
|
||||
with multi-precision integers is the kernel of choice for well-behaved
|
||||
algorithms. Note, that unless you use an arbitrary precision integer
|
||||
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,
|
||||
so you need to use a field type with Cartesian
|
||||
representation or have to switch to homogeneous representation.
|
||||
`double` is a possible, but imprecise field type. You can also
|
||||
put any ring type into `Quotient` to get a field type and put it
|
||||
into `Cartesian`, but you better put the ring type into
|
||||
`Homogeneous`. `leda_rational` and `leda_real` are valid
|
||||
field types, too.
|
||||
|
||||
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.
|
||||
|
||||
## Inclusion of Header Files ##
|
||||
|
||||
You need just to include a representation class to obtain the
|
||||
geometric objects of the kernel that you would like to use with the
|
||||
representation class, i.e., `CGAL/Cartesian_d.h` or
|
||||
`CGAL/Homogeneous_d.h`
|
||||
|
||||
# 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}
|
||||
double coord[] = {1.0, 1.0, 1.0, 1.0};
|
||||
Point_d< Cartesian_d<double> > p(4,coord,coord+4), q(4);
|
||||
Vector_d< Cartesian_d<double> > v(4);
|
||||
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_d<R>`), vectors (`Vector_d<R>`), and
|
||||
directions (`Direction_d<R>`), \cgal provides lines, rays,
|
||||
segments, hyperplanes, and spheres.
|
||||
|
||||
Lines (`Line_d<R>`) in \cgal are oriented. A ray
|
||||
(`Ray_d<R>`) is a 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_d<R>`) 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.
|
||||
|
||||
Hyperplanes are affine subspaces of dimension \f$ d-1\f$ in \f$ \E^d\f$, passing
|
||||
through \f$ d\f$ points. Hyperplanes are oriented and partition space into
|
||||
a positive side and a negative side. In \cgal, there are no special
|
||||
classes for halfspaces. Halfspaces are supposed to be represented by
|
||||
oriented hyperplanes. All kernel objects are equality comparable via
|
||||
`operator==` and `operator!=`. For those oriented objects
|
||||
whose orientation can be reversed (segments, lines, hyperplanes,
|
||||
spheres) there is also a global function `weak_equality` that
|
||||
allows to test for point set equality disregarding the orientation.
|
||||
|
||||
## 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.
|
||||
halfspaces and hyperplanes are not distinguished, neither are balls
|
||||
and spheres. Such objects split the ambient space into two
|
||||
full-dimensional parts, a bounded part and an unbounded part (e.g.
|
||||
spheres), 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 segment in \f$ d\f$-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 (also called functors and provided by a kernel class).
|
||||
|
||||
\cgal provides predicates for the orientation of
|
||||
point sets (`orientation`), for comparing points according to some
|
||||
given order, especially for comparing Cartesian coordinates
|
||||
(e.g. `lexicographically_xy_smaller`), 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_d<R>`) allow to
|
||||
generate new object instances under arbitrary affine transformations.
|
||||
These transformations include translations, rotations (within planes)
|
||||
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
|
||||
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>
|
||||
|
||||
## Intersection and Polymorphic Return Values ##
|
||||
|
||||
Intersections on kernel objects currently cover only those objects
|
||||
that are part of flats (`Segment_d<R>`, `Ray_d<R>`,
|
||||
`Line_c<R>`, and `Hyperplane_d<R>`). For any pair of objects
|
||||
\f$ o1\f$, \f$ o2\f$ of these types the operation `intersection(o1,o2)`
|
||||
returns a polymorphic object that wraps the result of the intersection
|
||||
operation.
|
||||
|
||||
The class `Object` provides the polymorphic abstraction. An
|
||||
object `obj` of type `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 unwrap the encapsulated class.
|
||||
|
||||
### Example ###
|
||||
|
||||
In the following example, the object type is used as a return value for
|
||||
the intersection computation, as there are
|
||||
possibly different return values.
|
||||
|
||||
\code{.cpp}
|
||||
typedef Point_d< Cartesian_d<double> > Point;
|
||||
typedef Segment_d< Cartesian_d<double> > Segment;
|
||||
Segment s1, s2;
|
||||
std::cin >> s1 >> s2;
|
||||
Object obj = intersection(s1, s2);
|
||||
if (const Point *p = object_cast<Point>(&obj) ) {
|
||||
// do something with *p
|
||||
} else if (const Segment *s = object_cast<Segment>(&obj) ) {
|
||||
// do something with *s
|
||||
}
|
||||
// there was no intersection
|
||||
\endcode
|
||||
|
||||
## Constructive Predicates ##
|
||||
|
||||
For testing where a point \f$ p\f$ lies with respect to a hyperplane
|
||||
defined by an array \f$ P\f$ of points \f$ p_1\f$, ... , \f$ p_d\f$, one may be
|
||||
tempted to construct the hyperplane `Hyperplane_d<R>(d,P,P+d)` 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_1\f$, ... , \f$ p_d\f$, \f$ p\f$.
|
||||
|
||||
In \cgal, we provide predicates in which such geometric decisions
|
||||
are made directly with a reference to the input points in \f$ P\f$ without
|
||||
an intermediary object like a plane. For the above test, the
|
||||
recommended way to get the result is to use
|
||||
`orientation(P',P'+d)`, where \f$ P'\f$ is an array containing the
|
||||
points \f$ p_1\f$, ... , \f$ p_d\f$, \f$ p\f$.
|
||||
|
||||
For exact number types like `leda_real`, 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)`.
|
||||
|
||||
# Design and Implementation History #
|
||||
|
||||
This higher-dimensional kernel is the result of a long evolving
|
||||
development. A first version of the kernel was offered as a LEDA
|
||||
extension package ddgeo by Kurt Mehlhorn and Michael Seel. The
|
||||
original design was driven by the realization of a d-dimensional
|
||||
convex hull data type developed at the
|
||||
Max-Planck Institut für Informatik.
|
||||
|
||||
The code base was discussed and reviewed within the \cgal kernel group
|
||||
(of the low-dimensional kernel). This led to the identification of
|
||||
the concept interfaces and in parallel to adaptations according to the
|
||||
evolution of the low-dimensional kernel. The kernel was revised
|
||||
based on suggestions by Hervé Brönnimann, Michael Hoffmann, and
|
||||
Stefan Schirra.
|
||||
|
||||
## Acknowledgments ##
|
||||
|
||||
This work was supported by ESPRIT IV Long Term Research Projects
|
||||
No. 21957 (CGAL) and No. 28155 (GALIA).
|
||||
|
||||
*/
|
||||
} /* namespace CGAL */
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/// \defgroup PkgKernelD dD Geometry Kernel
|
||||
|
||||
/// \defgroup PkgKernelDLinAlgConcepts Linear Algebra Concepts
|
||||
/// \ingroup PkgKernelD
|
||||
|
||||
/// \defgroup PkgKernelDLinAlgClasses Linear Algebra Classes
|
||||
/// \ingroup PkgKernelD
|
||||
|
||||
/// \defgroup PkgKernelDKernels Kernels
|
||||
/// \ingroup PkgKernelD
|
||||
|
||||
/// \defgroup PkgKernelDKernelObjs Kernel Objects
|
||||
/// \ingroup PkgKernelD
|
||||
|
||||
/// \defgroup PkgKernelDFunctions Global Kernel Functions
|
||||
/// \ingroup PkgKernelD
|
||||
|
||||
/// \defgroup PkgKernelDKernelConcept Kernel Concept
|
||||
/// \ingroup PkgKernelD
|
||||
|
||||
|
||||
/*!
|
||||
\addtogroup PkgKernelD
|
||||
\todo check generated documentation
|
||||
\PkgDescriptionBegin{dD Geometry Kernel}
|
||||
\PkgPicture{hypercube.png}
|
||||
\PkgAuthor{Michael Seel}
|
||||
\PkgDesc{The dD Kernel contains objects of constant size, such as point, vector, direction, line, ray, segment, circle in d dimensional Euclidean space, as well as predicates and constructions for these objects.}
|
||||
\PkgSince{1.1}
|
||||
\cgalbib{cgal:s-gkd}
|
||||
\license{\ref licensesLGPL "LGPL"}
|
||||
\PkgDescriptionEnd
|
||||
*/
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Loading…
Reference in New Issue