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

### Creation

 Direction_d dir; introduces a variable dir of type Direction_d. Direction_d dir ( Vector_d v); introduces a variable dir of type Direction_d initialized to the direction of v. template Direction_d dir ( int d, InputIterator first, InputIterator last); introduces a variable dir of type Direction_d 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 dir ( int d, Base_direction, int i); returns a variable dir of type Direction_d initialized to the direction of the i-th base vector of dimension d. Precondition: 0 i < d. Direction_d dir ( RT x, RT y); introduces a variable dir of type Direction_d in 2-dimensional space. Direction_d dir ( RT x, RT y, RT z); introduces a variable dir of type Direction_d 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 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 dir.transform ( Aff_transformation_d t) returns t(p). Direction_d dir.opposite () returns the direction opposite to dir. Direction_d - 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()).