## CGAL::Direction_d<Kernel>

### Definition

A Direction_d is a vector in the d-dimensional vector space where we forget about its length. We represent directions in d-dimensional space as a tuple (h0,...,hd) of variables of type RT which we call the homogeneous coordinates of the direction. The coordinate hd must be positive. The Cartesian coordinates of a direction are ci = hi/hd for 0 i < d, 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.

### Types

Direction_d<Kernel>::RT
| the ring type.
Direction_d<Kernel>::FT
| the field type.
Direction_d<Kernel>::LA
| the linear algebra layer.
Direction_d<Kernel>::Delta_const_iterator
| a read-only iterator for the deltas of dir.
Direction_d<Kernel>::Base_direction
| construction tag.

### Creation

Direction_d<Kernel> dir;
| introduces a variable dir of type Direction_d<Kernel>.
Direction_d<Kernel> dir ( Vector_d<Kernel> v);
| introduces a variable dir of type Direction_d<Kernel> initialized to the direction of v.
template <class InputIterator>
Direction_d<Kernel> dir ( int d, InputIterator first, InputIterator last);
| introduces a variable dir of type Direction_d<Kernel> in dimension d with representation tuple set [first,last). Precondition: d is nonnegative, [first,last) has d elements. Requirement: The value type of InputIterator is RT.
Direction_d<Kernel> dir ( int d, Base_direction, int i);
| returns a variable dir of type Direction_d<Kernel> initialized to the direction of the i-th base vector of dimension d. Precondition: 0 i < d.
Direction_d<Kernel> dir ( RT x, RT y);
| introduces a variable dir of type Direction_d<Kernel> in 2-dimensional space.
Direction_d<Kernel> dir ( RT x, RT y, RT z);
| introduces a variable dir of type Direction_d<Kernel> in 3-dimensional space.

### Operations

int | dir.dimension () | returns the dimension of dir.
RT | dir.delta ( int i) | returns the i-th component of dir. Precondition: 0 i < d.
RT | dir [ int i] | returns the i-th delta of dir. Precondition: 0 i < d.
Delta_const_iterator
| dir.deltas_begin ()
|  | returns an iterator pointing to the first delta of dir.
Delta_const_iterator
| dir.deltas_end () | returns an iterator pointing beyond the last delta of dir.
Vector_d<Kernel> | dir.vector () | returns a vector pointing in direction dir.
bool | dir.is_degenerate ()
|  | returns true iff dir.delta(i)==0 for all 0 i < d.
Direction_d<Kernel>
| dir.transform ( Aff_transformation_d<Kernel> t)
|  | returns t(p).
Direction_d<Kernel>
| dir.opposite () | returns the direction opposite to dir.
Direction_d<Kernel>
| - dir | returns the direction opposite to dir.

### 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 d take time O(d.dimension()). dimension(), coordinate access and conversion take constant time. The space requirement is O(d.dimension()).