An object of the class Polytope_distance_d<Traits> represents the (squared) distance between two convex polytopes, given as the convex hulls of two finite point sets in d-dimensional Euclidean space d. For point sets P and Q we denote by pd(P,Q) the distance between the convex hulls of P and Q. Note that pd(P,Q) can be degenerate, i.e. pd(P,Q)=∞ if P or Q is empty.
Two inclusion-minimal subsets SP of P and SQ of Q with pd(SP,SQ)=pd(P,Q) are called pair of support sets, the points in SP and SQ are the support points. A pair of support sets has size at most d+2 (by size we mean |SP|+|SQ|). The distance between the two polytopes is realized by a pair of points p and q lying in the convex hull of SP and SQ, repectively, i.e. √||p-q||=pd(P,Q). In general, neither the support sets nor the realizing points are necessarily unique.
The underlying algorithm can cope with all kinds of input, e.g. P and Q may be in non-convex position or points may occur more than once. The algorithm computes a pair of support sets SP and SQ with realizing points p and q which remain fixed until the next set, insert, or clear operation.
#include <CGAL/Polytope_distance_d.h>
The template parameter Traits is a model for OptimisationDTraits.
We provide the models Optimisation_d_traits_2, Optimisation_d_traits_3, and Optimisation_d_traits_d using the two-, three-, and d-dimensional Cgal kernel, respectively.
Polytope_distance_d<Traits>::Point | |
typedef to Traits::Point_d.
Point type used to represent the input points.
| |
Polytope_distance_d<Traits>::FT | |
typedef to Traits::FT.
Number type used to return the squared distance
between the two polytopes.
| |
Polytope_distance_d<Traits>::ET | |
typedef to Traits::ET.
Number type used to do the exact computations in the underlying
solver for quadratic programs (cf. Implementation).
| |
Polytope_distance_d<Traits>::Point_iterator | |
non-mutable model of the STL concept RandomAccessIterator
with value type Point. Used to access the points
of the two polytopes.
| |
Polytope_distance_d<Traits>::Support_point_iterator | |
non-mutable model of the STL concept RandomAccessIterator
with value type Point. Used to access the support points.
| |
Polytope_distance_d<Traits>::Support_point_index_iterator | |
non-mutable model of the STL concept RandomAccessIterator
with value type int. Used to access the indices of the
support points in the provided input order (starting from 0
in both point sets).
| |
Polytope_distance_d<Traits>::Coordinate_iterator | |
non-mutable model of the STL concept RandomAccessIterator
with value type ET. Used to access the coordinates of
the realizing points.
|
Polytope_distance_d<Traits> poly_dist ( Traits traits = Traits(), int verbose = 0, std::ostream& stream = std::cout); | |||||
initializes poly_dist to pd(∅, ∅).
| |||||
template < class InputIterator1, class InputIterator2 > | |||||
| |||||
initializes poly_dist to pd(P,Q) with P and Q being the
sets of points in the range [p_first,p_last) and
[q_first,q_last), respectively.
|
int | poly_dist.ambient_dimension () const | |
returns the dimension of the points in P and Q. If poly_dist is pd(∅, ∅), the ambient dimension is -1. |
int | poly_dist.number_of_points () const | |
returns the number of all points of poly_dist, i.e. |P|+|Q|. | ||
int | poly_dist.number_of_points_p () const | |
returns the number of points in P. | ||
int | poly_dist.number_of_points_q () const | |
returns the number of points in Q. |
int | poly_dist.number_of_support_points () const | |
returns the number of support points of poly_dist, i.e. |SP|+|SQ|. | ||
int | poly_dist.number_of_support_points_p () const | |
returns the number of support points in SP. | ||
int | poly_dist.number_of_support_points_q () const | |
returns the number of support points in SQ. |
Point_iterator | poly_dist.points_p_begin () const | returns an iterator referring to the first point in P. |
Point_iterator | poly_dist.points_p_end () const | returns the corresponding past-the-end iterator. |
Point_iterator | poly_dist.points_q_begin () const | returns an iterator referring to the first point in Q. |
Point_iterator | poly_dist.points_q_end () const | returns the corresponding past-the-end iterator. |
Coordinate_iterator | poly_dist.realizing_point_p_coordinates_begin () const | |||
returns an iterator referring to the first coordinate of the
realizing point of P.
| ||||
Coordinate_iterator | poly_dist.realizing_point_p_coordinates_end () const | |||
returns the corresponding past-the-end iterator. |
Coordinate_iterator | poly_dist.realizing_point_q_coordinates_begin () const | |||
returns an iterator referring to the first coordinate of the
realizing point of Q.
| ||||
Coordinate_iterator | poly_dist.realizing_point_q_coordinates_end () const | |||
returns the corresponding past-the-end iterator. | ||||
ET | poly_dist.squared_distance_numerator () const | |||
returns the numerator of the squared distance of poly_dist. | ||||
ET | poly_dist.squared_distance_denominator () const | |||
returns the denominator of the squared distance of poly_dist. |
bool | poly_dist.is_finite () const | returns true, if pd(P,Q) is finite, i.e. none of the two polytopes is empty. |
bool | poly_dist.is_zero () const | returns true, if pd(P,Q) is zero, i.e. the two polytopes intersect (this implies degeneracy). |
bool | poly_dist.is_degenerate () const | returns true, iff pd(P,Q) is degenerate, i.e. pd(P,Q) is not finite. |
void | poly_dist.clear () | resets poly_dist to pd(∅, ∅). | ||||
template < class InputIterator1, class InputIterator2 > | ||||||
void |
| |||||
sets poly_dist to pd(P,Q) with P and Q being the sets of
points in the ranges [p_first,p_last) and
[q_first,q_last), respectively.
| ||||||
template < class InputIterator > | ||||||
void | poly_dist.set_p ( InputIterator p_first, InputIterator p_last) | |||||
sets poly_dist to pd(P,Q) with P being the set of points
in the range [p_first,p_last) (Q remains unchanged).
| ||||||
template < class InputIterator > | ||||||
void | poly_dist.set_q ( InputIterator q_first, InputIterator q_last) | |||||
sets poly_dist to pd(P,Q) with Q being the set of points
in the range [q_first,q_last) (P remains unchanged).
| ||||||
void | poly_dist.insert_p ( Point p) |
inserts p into P.
| ||||
void | poly_dist.insert_q ( Point q) |
inserts q into Q.
| ||||
template < class InputIterator1, class InputIterator2 > | ||||||
void |
| |||||
inserts the points in the range [p_first,p_last)
and [q_first,q_last) into P and Q, respectively,
and recomputes the (squared) distance.
| ||||||
template < class InputIterator > | ||||||
void | poly_dist.insert_p ( InputIterator p_first, InputIterator p_last) | |||||
inserts the points in the range [p_first,p_last) into
P and recomputes the (squared) distance (Q remains unchanged).
| ||||||
template < class InputIterator > | ||||||
void | poly_dist.insert_q ( InputIterator q_first, InputIterator q_last) | |||||
inserts the points in the range [q_first,q_last) into
Q and recomputes the (squared) distance (P remains unchanged).
|
An object poly_dist is valid, iff
bool | poly_dist.is_valid ( bool verbose = false, int level = 0) const | |
returns true, iff poly_dist is valid. If verbose is true, some messages concerning the performed checks are written to standard error stream. The second parameter level is not used, we provide it only for consistency with interfaces of other classes. |
const Traits& | poly_dist.traits () const | returns a const reference to the traits class object. |
std::ostream& | std::ostream& os << poly_dist |
writes poly_dist to output stream os.
| ||
std::istream& | std::istream& is >> poly_dist& |
reads poly_dist from input stream is.
|
CGAL::Optimisation_d_traits_2<K,ET,NT>
CGAL::Optimisation_d_traits_3<K,ET,NT>
CGAL::Optimisation_d_traits_d<K,ET,NT>
OptimisationDTraits
The problem of finding the distance between two convex polytopes given as the convex hulls of two finite point sets can be formulated as an optimization problem with linear constraints and a convex quadratic objective function. The solution is obtained using our exact solver for quadratic programs [GS00].
The creation time is almost always linear in the number of points. Access functions and predicates take constant time, inserting a point might take up to linear time. The clear operation and the check for validity each take linear time.