CGAL 4.4 - dD Geometry Kernel
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
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=(p0,,pd1) in d-dimensional space can be represented by homogeneous coordinates (h0,h1,,hd) of number type RT such that pi=hi/hd, which is of type FT. The homogenizing coordinate hd is positive.

We call pi, 0i<d the i-th Cartesian coordinate and hi, 0id, 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: (±H[0],±H[1],,±H[d1],±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 p0 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 h0 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 pO.
 
Vector_d< Kerneloperator- (const Point_d< Kernel > &q)
 returns pq. More...
 
Point_d< Kerneloperator+ (const Vector_d< Kernel > &v)
 returns p+v. More...
 
Point_d< Kerneloperator- (const Vector_d< Kernel > &v)
 returns pv. 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.
 

Constructor & Destructor Documentation

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)=(±h0,±h1,,±hd) where the sign chosen is the sign of hd.

Precondition
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<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: (±H[0],±H[1],,±H[d1],±D).

The sign chosen is the sign of D.

Precondition
D is non-zero, the iterator range defines a d-tuple of RT.
Requires:
The value type of InputIterator is RT.
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
w0.
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
w0.

Member Function Documentation

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

returns the i-th Cartesian coordinate of p.

Precondition
0i<d.
template<typename Kernel >
RT CGAL::Point_d< Kernel >::homogeneous ( int  i)

returns the i-th homogeneous coordinate of p.

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

returns p+v.

Precondition
p.dimension() == v.dimension().
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().
template<typename Kernel >
Vector_d<Kernel> CGAL::Point_d< Kernel >::operator- ( const Point_d< Kernel > &  q)

returns pq.

Precondition
p.dimension() == q.dimension().
template<typename Kernel >
Point_d<Kernel> CGAL::Point_d< Kernel >::operator- ( const Vector_d< Kernel > &  v)

returns pv.

Precondition
p.dimension() == v.dimension().
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().
template<typename Kernel >
FT CGAL::Point_d< Kernel >::operator[] ( int  i)

returns the i-th Cartesian coordinate of p.

Precondition
0i<d.