CGAL 4.9 - dD Geometry Kernel
|
#include <CGAL/Kernel_d/Vector_d.h>
An instance of data type Vector_d<Kernel>
is a vector of Euclidean space in dimension \( d\).
A vector \( r = (r_0,\ldots,r_{ d - 1})\) can be represented in homogeneous coordinates \( (h_0,\ldots,h_d)\) of number type RT
, such that \( r_i = h_i/h_d\) which is of type FT
. We call the \( r_i\)'s the Cartesian coordinates of the vector. The homogenizing coordinate \( h_d\) is positive.
This data type is meant for use in computational geometry. It realizes free vectors as opposed to position vectors (type Point_d
). The main difference between position vectors and free vectors is their behavior under affine transformations, e.g., free vectors are invariant under translations.
Downward compatibility
We provide all operations of the lower dimensional interface x()
, y()
, z()
, hx()
, hy()
, hz()
, hw()
.
Implementation
Vectors are implemented by arrays of variables of type RT
. All operations like creation, initialization, tests, vector arithmetic, input and output on a vector \( v\) take time \( O(v.dimension())\). coordinate access, dimension()
and conversions take constant time. The space requirement of a vector is \( O(v.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. | |
typedef unspecified_type | Base_vector |
construction tag. | |
Creation | |
Vector_d () | |
introduces a variable v of type Vector_d<Kernel> . | |
Vector_d (int d, Null_vector) | |
introduces the zero vector v of type Vector_d<Kernel> in \( d\)-dimensional space. More... | |
template<class InputIterator > | |
Vector_d (int d, InputIterator first, InputIterator last) | |
introduces a variable v of type Vector_d<Kernel> in dimension d . More... | |
template<class InputIterator > | |
Vector_d (int d, InputIterator first, InputIterator last, RT D) | |
introduces a variable v of type Vector_d<Kernel> in dimension d initialized to the vector with homogeneous coordinates as defined by H = set [first,last) and D : \( (\pmH[0], \pmH[1], \ldots, \pmH[d-1], \pmD)\). More... | |
Vector_d (int d, Base_vector, int i) | |
returns a variable v of type Vector_d<Kernel> initialized to the \( i\)-th base vector of dimension \( d\). More... | |
Vector_d (RT x, RT y, RT w=1) | |
introduces a variable v of type Vector_d<Kernel> in \( 2\)-dimensional space. More... | |
Vector_d (RT x, RT y, RT z, RT w) | |
introduces a variable v of type Vector_d<Kernel> in \( 3\)-dimensional space. More... | |
Operations | |
int | dimension () |
returns the dimension of v . | |
FT | cartesian (int i) |
returns the \( i\)-th Cartesian coordinate of v . More... | |
FT | operator[] (int i) |
returns the \( i\)-th Cartesian coordinate of v . More... | |
RT | homogeneous (int i) |
returns the \( i\)-th homogeneous coordinate of v . More... | |
FT | squared_length () |
returns the square of the length of v . | |
Cartesian_const_iterator | cartesian_begin () |
returns an iterator pointing to the zeroth Cartesian coordinate of v . | |
Cartesian_const_iterator | cartesian_end () |
returns an iterator pointing beyond the last Cartesian coordinate of v . | |
Homogeneous_const_iterator | homogeneous_begin () |
returns an iterator pointing to the zeroth homogeneous coordinate of v . | |
Homogeneous_const_iterator | homogeneous_end () |
returns an iterator pointing beyond the last homogeneous coordinate of v . | |
Direction_d< Kernel > | direction () |
returns the direction of v . | |
Vector_d< Kernel > | transform (const Aff_transformation_d< Kernel > &t) |
returns \( t(v)\). | |
Arithmetic Operators, Tests and IO | |
Vector_d< Kernel > & | operator*= (const RT &n) |
multiplies all Cartesian coordinates by n . | |
Vector_d< Kernel > & | operator*= (const FT &r) |
multiplies all Cartesian coordinates by r . | |
Vector_d< Kernel > | operator/ (const RT &n) |
returns the vector with Cartesian coordinates \( v_i/n, 0 \leq i < d\). | |
Vector_d< Kernel > | operator/ (const FT &r) |
returns the vector with Cartesian coordinates \( v_i/r, 0 \leq i < d\). | |
Vector_d< Kernel > & | operator/= (const RT &n) |
divides all Cartesian coordinates by n . | |
Vector_d< Kernel > & | operator/= (const FT &r) |
divides all Cartesian coordinates by r . | |
FT | operator* (const Vector_d< Kernel > &w) |
inner product, i.e., \( \sum_{ 0 \le i < d } v_i w_i\), where \( v_i\) and \( w_i\) are the Cartesian coordinates of \( v\) and \( w\) respectively. | |
Vector_d< Kernel > | operator+ (const Vector_d< Kernel > &w) |
returns the vector with Cartesian coordinates \( v_i+w_i, 0 \leq i < d\). | |
Vector_d< Kernel > & | operator+= (const Vector_d< Kernel > &w) |
addition plus assignment. | |
Vector_d< Kernel > | operator- (const Vector_d< Kernel > &w) |
returns the vector with Cartesian coordinates \( v_i-w_i, 0 \leq i < d\). | |
Vector_d< Kernel > & | operator-= (const Vector_d< Kernel > &w) |
subtraction plus assignment. | |
Vector_d< Kernel > | operator- () |
returns the vector in opposite direction. | |
bool | is_zero () |
returns true if v is the zero vector. | |
Vector_d< Kernel > | operator* (const RT &n, const Vector_d< Kernel > &v) |
returns the vector with Cartesian coordinates \( n v_i\). | |
Vector_d< Kernel > | operator* (const FT &r, const Vector_d< Kernel > &v) |
returns the vector with Cartesian coordinates \( r v_i, 0 \leq i < d\). | |
CGAL::Vector_d< Kernel >::Vector_d | ( | int | d, |
Null_vector | |||
) |
introduces the zero vector v
of type Vector_d<Kernel>
in \( d\)-dimensional space.
For the creation flag CGAL::NULL_VECTOR
can be used.
CGAL::Vector_d< Kernel >::Vector_d | ( | int | d, |
InputIterator | first, | ||
InputIterator | last | ||
) |
introduces a variable v
of type Vector_d<Kernel>
in dimension d
.
If size [first,last) == d
this creates a vector with Cartesian coordinates set [first,last)
. If size [first,last) == p+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\).
d
is nonnegative, [first,last)
has d
or d+1
elements where the last has to be non-zero. InputIterator | has RT as value type. |
CGAL::Vector_d< Kernel >::Vector_d | ( | int | d, |
InputIterator | first, | ||
InputIterator | last, | ||
RT | D | ||
) |
introduces a variable v
of type Vector_d<Kernel>
in dimension d
initialized to the vector with homogeneous coordinates as defined by H = set [first,last)
and D
: \( (\pmH[0], \pmH[1], \ldots, \pmH[d-1], \pmD)\).
The sign chosen is the sign of \( D\).
D
is non-zero, the iterator range defines a \( d\)-tuple of RT
. InputIterator | has RT as value type. |
CGAL::Vector_d< Kernel >::Vector_d | ( | int | d, |
Base_vector | , | ||
int | i | ||
) |
CGAL::Vector_d< Kernel >::Vector_d | ( | RT | x, |
RT | y, | ||
RT | w = 1 |
||
) |
CGAL::Vector_d< Kernel >::Vector_d | ( | RT | x, |
RT | y, | ||
RT | z, | ||
RT | w | ||
) |
FT CGAL::Vector_d< Kernel >::cartesian | ( | int | i) |
returns the \( i\)-th Cartesian coordinate of v
.
RT CGAL::Vector_d< Kernel >::homogeneous | ( | int | i) |
returns the \( i\)-th homogeneous coordinate of v
.
FT CGAL::Vector_d< Kernel >::operator[] | ( | int | i) |
returns the \( i\)-th Cartesian coordinate of v
.