CGAL 5.4 - dD Geometry Kernel
CGAL::Point_d< Kernel > Class Template Reference

#include <CGAL/Kernel_d/Point_d.h>

Definition

An instance of data type Point_d<Kernel> is a point of Euclidean space in dimension \( d\).

A point \( p = (p_0,\ldots,p_{ d - 1 })\) in \( d\)-dimensional space can be represented by homogeneous coordinates \( (h_0,h_1,\ldots,h_d)\) of number type RT such that \( p_i = h_i/h_d\), which is of type FT. The homogenizing coordinate \( h_d\) is positive.

We call \( p_i\), \( 0 \leq i < d\) the \( i\)-th Cartesian coordinate and \( h_i\), \( 0 \le i \le d\), the \( i\)-th homogeneous coordinate. We call \( d\) 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 \( p\) take time \( O(p.dimension())\). dimension(), coordinate access and conversions take constant time. The space requirement for points is \( O(p.dimension())\).

Types

typedef unspecified_type LA
 the linear algebra layer.
 
typedef unspecified_type Cartesian_const_iterator
 a read-only iterator for the Cartesian coordinates.
 
typedef unspecified_type Homogeneous_const_iterator
 a read-only iterator for the homogeneous coordinates.
 

Creation

 Point_d ()
 introduces a variable p of type Point_d<Kernel>.
 
 Point_d (int d, Origin)
 introduces a variable p of type Point_d<Kernel> in \( d\)-dimensional space, initialized to the origin.
 
template<class InputIterator >
 Point_d (int d, InputIterator first, InputIterator last)
 introduces a variable p of type Point_d<Kernel> in dimension d. More...
 
template<class InputIterator >
 Point_d (int d, InputIterator first, InputIterator last, RT D)
 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: \( (\pm H[0], \pm H[1], \ldots, \pm H[d-1], \pm D)\). More...
 
 Point_d (RT x, RT y, RT w=1)
 introduces a variable p of type Point_d<Kernel> in \( 2\)-dimensional space. More...
 
 Point_d (RT x, RT y, RT z, RT w)
 introduces a variable p of type Point_d<Kernel> in \( 3\)-dimensional space. More...
 

Operations

int dimension ()
 returns the dimension of p.
 
FT cartesian (int i)
 returns the \( i\)-th Cartesian coordinate of p. More...
 
FT operator[] (int i)
 returns the \( i\)-th Cartesian coordinate of p. More...
 
RT homogeneous (int i)
 returns the \( i\)-th homogeneous coordinate of p. More...
 
Cartesian_const_iterator cartesian_begin ()
 returns an iterator pointing to the zeroth Cartesian coordinate \( p_0\) of p.
 
Cartesian_const_iterator cartesian_end ()
 returns an iterator pointing beyond the last Cartesian coordinate of p.
 
Homogeneous_const_iterator homogeneous_begin ()
 returns an iterator pointing to the zeroth homogeneous coordinate \( h_0\) of p.
 
Homogeneous_const_iterator homogeneous_end ()
 returns an iterator pointing beyond the last homogeneous coordinate of p.
 
Point_d< Kerneltransform (const Aff_transformation_d< Kernel > &t)
 returns \( t(p)\).
 

Arithmetic Operators, Tests and IO

Vector_d< Kerneloperator- (const Origin &o)
 returns the vector \( p-O\).
 
Vector_d< Kerneloperator- (const Point_d< Kernel > &q)
 returns \( p - q\). More...
 
Point_d< Kerneloperator+ (const Vector_d< Kernel > &v)
 returns \( p + v\). More...
 
Point_d< Kerneloperator- (const Vector_d< Kernel > &v)
 returns \( p - v\). More...
 
Point_d< Kernel > & operator+= (const Vector_d< Kernel > &v)
 adds v to p. More...
 
Point_d< Kernel > & operator-= (const Vector_d< Kernel > &v)
 subtracts v from p. More...
 
bool operator== (const Origin &)
 returns true if p is the origin.
 
bool operator< (const Point_d< Kernel > &q)
 returns true iff p is lexicographically smaller than q with respect to Cartesian lexicographic order of points. More...
 
bool operator> (const Point_d< Kernel > &q)
 returns true iff p is lexicographically greater than q with respect to Cartesian lexicographic order of points. More...
 
bool operator<= (const Point_d< Kernel > &q)
 returns true iff p is lexicographically smaller than or equal to q with respect to Cartesian lexicographic order of points. More...
 
bool operator>= (const Point_d< Kernel > &q)
 returns true iff p is lexicographically greater than or equal to q with respect to Cartesian lexicographic order of points. More...
 

Constructor & Destructor Documentation

◆ Point_d() [1/4]

template<typename Kernel >
template<class InputIterator >
CGAL::Point_d< Kernel >::Point_d ( int  d,
InputIterator  first,
InputIterator  last 
)

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 \( H = set [first,last) = (\pm h_0, \pm h_1, \ldots, \pm h_d)\) where the sign chosen is the sign of \( h_d\).

Precondition
d is nonnegative, [first,last) has d or d+1 elements where the last has to be non-zero.
Template Parameters
InputIteratorhas RT as value type.

◆ Point_d() [2/4]

template<typename Kernel >
template<class InputIterator >
CGAL::Point_d< Kernel >::Point_d ( int  d,
InputIterator  first,
InputIterator  last,
RT  D 
)

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: \( (\pm H[0], \pm H[1], \ldots, \pm H[d-1], \pm D)\).

The sign chosen is the sign of \( D\).

Precondition
D is non-zero, the iterator range defines a \( d\)-tuple of RT.
Template Parameters
InputIteratorhas RT as value type.

◆ Point_d() [3/4]

template<typename Kernel >
CGAL::Point_d< Kernel >::Point_d ( RT  x,
RT  y,
RT  w = 1 
)

introduces a variable p of type Point_d<Kernel> in \( 2\)-dimensional space.

Precondition
\( w \neq0\).

◆ Point_d() [4/4]

template<typename Kernel >
CGAL::Point_d< Kernel >::Point_d ( RT  x,
RT  y,
RT  z,
RT  w 
)

introduces a variable p of type Point_d<Kernel> in \( 3\)-dimensional space.

Precondition
\( w \neq0\).

Member Function Documentation

◆ cartesian()

template<typename Kernel >
FT CGAL::Point_d< Kernel >::cartesian ( int  i)

returns the \( i\)-th Cartesian coordinate of p.

Precondition
\( 0 \leq i < d\).

◆ homogeneous()

template<typename Kernel >
RT CGAL::Point_d< Kernel >::homogeneous ( int  i)

returns the \( i\)-th homogeneous coordinate of p.

Precondition
\( 0 \leq i \leq d\).

◆ operator+()

template<typename Kernel >
Point_d<Kernel> CGAL::Point_d< Kernel >::operator+ ( const Vector_d< Kernel > &  v)

returns \( p + v\).

Precondition
p.dimension() == v.dimension().

◆ operator+=()

template<typename Kernel >
Point_d<Kernel>& CGAL::Point_d< Kernel >::operator+= ( const Vector_d< Kernel > &  v)

adds v to p.

Precondition
p.dimension() == v.dimension().

◆ operator-() [1/2]

template<typename Kernel >
Vector_d<Kernel> CGAL::Point_d< Kernel >::operator- ( const Point_d< Kernel > &  q)

returns \( p - q\).

Precondition
p.dimension() == q.dimension().

◆ operator-() [2/2]

template<typename Kernel >
Point_d<Kernel> CGAL::Point_d< Kernel >::operator- ( const Vector_d< Kernel > &  v)

returns \( p - v\).

Precondition
p.dimension() == v.dimension().

◆ operator-=()

template<typename Kernel >
Point_d<Kernel>& CGAL::Point_d< Kernel >::operator-= ( const Vector_d< Kernel > &  v)

subtracts v from p.

Precondition
p.dimension() == v.dimension().

◆ operator
template<typename Kernel >
bool CGAL::Point_d< Kernel >::operator< ( const Point_d< Kernel > &  q)

returns true iff p is lexicographically smaller than q with respect to Cartesian lexicographic order of points.

Precondition
p.dimension() == q.dimension().

◆ operator<=()

template<typename Kernel >
bool CGAL::Point_d< Kernel >::operator<= ( const Point_d< Kernel > &  q)

returns true iff p is lexicographically smaller than or equal to q with respect to Cartesian lexicographic order of points.

Precondition
p.dimension() == q.dimension().

◆ operator>()

template<typename Kernel >
bool CGAL::Point_d< Kernel >::operator> ( const Point_d< Kernel > &  q)

returns true iff p is lexicographically greater than q with respect to Cartesian lexicographic order of points.

Precondition
p.dimension() == q.dimension().

◆ operator>=()

template<typename Kernel >
bool CGAL::Point_d< Kernel >::operator>= ( const Point_d< Kernel > &  q)

returns true iff p is lexicographically greater than or equal to q with respect to Cartesian lexicographic order of points.

Precondition
p.dimension() == q.dimension().

◆ operator[]()

template<typename Kernel >
FT CGAL::Point_d< Kernel >::operator[] ( int  i)

returns the \( i\)-th Cartesian coordinate of p.

Precondition
\( 0 \leq i < d\).