CGAL::Point_d<Kernel>

Definition

An instance of data type Point_d<Kernel> is a point of Euclidean space in dimension d. A point p = (p0, ,p d - 1 ) 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, 0 i < d the i-th Cartesian coordinate and hi, 0 i d, the i-th homogeneous coordinate. We call d the dimension of the point.

Types

Point_d<Kernel>::LA
the linear algebra layer.


Point_d<Kernel>::Cartesian_const_iterator
a read-only iterator for the Cartesian coordinates.


Point_d<Kernel>::Homogeneous_const_iterator
a read-only iterator for the homogeneous coordinates.

Creation

Point_d<Kernel> p;
introduces a variable p of type Point_d<Kernel>.


Point_d<Kernel> p ( 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<Kernel> p ( 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.
Requirement: The value type of InputIterator is RT.


template <class InputIterator>
Point_d<Kernel> p ( 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[d-1], ± D). The sign chosen is the sign of D.
Precondition: D is non-zero, the iterator range defines a d-tuple of RT.
Requirement: The value type of InputIterator is RT.


Point_d<Kernel> p ( RT x, RT y, RT w = 1);
introduces a variable p of type Point_d<Kernel> in 2-dimensional space.
Precondition: w 0.


Point_d<Kernel> p ( RT x, RT y, RT z, RT w);
introduces a variable p of type Point_d<Kernel> in 3-dimensional space.
Precondition: w 0.

Operations

int p.dimension () returns the dimension of p.

FT p.cartesian ( int i) returns the i-th Cartesian coordinate of p.
Precondition: 0 i < d.

FT p [ int i ] returns the i-th Cartesian coordinate of p.
Precondition: 0 i < d.

RT p.homogeneous ( int i) returns the i-th homogeneous coordinate of p.
Precondition: 0 i d.

Cartesian_const_iterator p.cartesian_begin () returns an iterator pointing to the zeroth Cartesian coordinate p0 of p.

Cartesian_const_iterator p.cartesian_end () returns an iterator pointing beyond the last Cartesian coordinate of p.

Homogeneous_const_iterator p.homogeneous_begin () returns an iterator pointing to the zeroth homogeneous coordinate h0 of p.

Homogeneous_const_iterator p.homogeneous_end () returns an iterator pointing beyond the last homogeneous coordinate of p.

Point_d<Kernel> p.transform ( Aff_transformation_d<Kernel> t)
returns t(p).

Arithmetic Operators, Tests and IO

Vector_d<Kernel> p - Origin o returns the vector p-O.

Vector_d<Kernel> p - q returns p - q.
Precondition: p.dimension() == q.dimension().

Point_d<Kernel> p + Vector_d<Kernel> v returns p + v.
Precondition: p.dimension() == v.dimension().

Point_d<Kernel> p - Vector_d<Kernel> v returns p - v.
Precondition: p.dimension() == v.dimension().

Point_d<Kernel>& p += Vector_d<Kernel> v adds v to p.
Precondition: p.dimension() == v.dimension().

Point_d<Kernel>& p -= Vector_d<Kernel> v subtracts v from p.
Precondition: p.dimension() == v.dimension().

bool p == Origin returns true if p is the origin.

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()).