\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)
CGAL 4.7 - 2D and 3D Linear Geometry Kernel
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
CGAL::Vector_3< Kernel > Class Template Reference

#include <CGAL/Vector_3.h>

Definition

An object of the class Vector_3 is a vector in the three-dimensional vector space \( \mathbb{R}^3\).

Geometrically spoken a vector is the difference of two points \( p_2\), \( p_1\) and denotes the direction and the distance from \( p_1\) to \( p_2\).

CGAL defines a symbolic constant NULL_VECTOR. We will explicitly state where you can pass this constant as an argument instead of a vector initialized with zeros.

See also
Kernel::Vector_3
CGAL::cross_product()
CGAL::determinant()

Public Member Functions

Vector_3< Kerneloperator- () const
 Returns the opposite vector. More...
 
Vector_3< Kerneloperator/ (const Kernel::RT &s) const
 Division by a scalar. More...
 
Kernel::FT squared_length () const
 returns the squared length of v. More...
 
Kernel::FT operator* (const Vector_3< Kernel > &w) const
 returns the scalar product (= inner product) of the two vectors. More...
 
Vector_3< Kerneloperator* (const Vector_3< Kernel > &v, const Kernel::RT &s)
 Multiplication with a scalar from the right. More...
 
Vector_3< Kerneloperator* (const Vector_3< Kernel > &v, const Kernel::FT &s)
 Multiplication with a scalar from the right. More...
 
Vector_3< Kerneloperator* (const Kernel::RT &s, const Vector_3< Kernel > &v)
 Multiplication with a scalar from the left. More...
 
Vector_3< Kerneloperator* (const Kernel::FT &s, const Vector_3< Kernel > &v)
 Multiplication with a scalar from the left. More...
 

Types

typedef unspecified_type Cartesian_const_iterator
 An iterator for enumerating the Cartesian coordinates of a vector. More...
 

Creation

 Vector_3 (const Point_3< Kernel > &a, const Point_3< Kernel > &b)
 introduces the vector b-a. More...
 
 Vector_3 (const Segment_3< Kernel > &s)
 introduces the vector s.target()-s.source(). More...
 
 Vector_3 (const Ray_3< Kernel > &r)
 introduces a vector having the same direction as r. More...
 
 Vector_3 (const Line_3< Kernel > &l)
 introduces a vector having the same direction as l. More...
 
 Vector_3 (const Null_vector &NULL_VECTOR)
 introduces a null vector v. More...
 
 Vector_3 (int x, int y, int z)
 introduces a vector v initialized to (x, y, z). More...
 
 Vector_3 (double x, double y, double z)
 introduces a vector v initialized to `(x, y, z). More...
 
 Vector_3 (const Kernel::RT &hx, const Kernel::RT &hy, const Kernel::RT &hz, const Kernel::RT &hw=RT(1))
 introduces a vector v initialized to `(hx/hw, hy/hw, hz/hw). More...
 
 Vector_3 (const Kernel::FT &x, const Kernel::FT &y, const Kernel::FT &z)
 introduces a vector v initialized to (x, y, z). More...
 

Operations

bool operator== (const Vector_3< Kernel > &w) const
 Test for equality: two vectors are equal, iff their \( x\), \( y\) and \( z\) coordinates are equal. More...
 
bool operator!= (const Vector_3< Kernel > &w) const
 Test for inequality. More...
 

Coordinate Access

There are two sets of coordinate access functions, namely to the homogeneous and to the Cartesian coordinates.

They can be used independently from the chosen kernel model. Note that you do not loose information with the homogeneous representation, because the FieldNumberType is a quotient.

Kernel::RT hx () const
 returns the homogeneous \( x\) coordinate. More...
 
Kernel::RT hy () const
 returns the homogeneous \( y\) coordinate. More...
 
Kernel::RT hz () const
 returns the homogeneous \( z\) coordinate. More...
 
Kernel::RT hw () const
 returns the homogenizing coordinate. More...
 
Kernel::FT x () const
 returns the x-coordinate of v, that is hx()/hw(). More...
 
Kernel::FT y () const
 returns the y-coordinate of v, that is hy()/hw(). More...
 
Kernel::FT z () const
 returns the z coordinate of v, that is hz()/hw(). More...
 

Convenience Operations

The following operations are for convenience and for compatibility with higher dimensional vectors.

Again they come in a Cartesian and homogeneous flavor.

Kernel::RT homogeneous (int i) const
 returns the i'th homogeneous coordinate of v, starting with 0. More...
 
Kernel::FT cartesian (int i) const
 returns the i'th Cartesian coordinate of v, starting at 0. More...
 
Kernel::FT operator[] (int i) const
 returns cartesian(i). More...
 
Cartesian_const_iterator cartesian_begin () const
 returns an iterator to the Cartesian coordinates of v, starting with the 0th coordinate. More...
 
Cartesian_const_iterator cartesian_end () const
 returns an off the end iterator to the Cartesian coordinates of v. More...
 
int dimension () const
 returns the dimension (the constant 3). More...
 
Vector_3< Kerneltransform (const Aff_transformation_3< Kernel > &t) const
 returns the vector obtained by applying t on v. More...
 
Direction_3< Kerneldirection () const
 returns the direction of v. More...
 

Operators

Vector_3< Kerneloperator+ (const Vector_3< Kernel > &w) const
 Addition. More...
 
Vector_3< Kerneloperator- (const Vector_3< Kernel > &w) const
 Subtraction. More...
 

Member Typedef Documentation

template<typename Kernel >
typedef unspecified_type CGAL::Vector_3< Kernel >::Cartesian_const_iterator

An iterator for enumerating the Cartesian coordinates of a vector.

Constructor & Destructor Documentation

template<typename Kernel >
CGAL::Vector_3< Kernel >::Vector_3 ( const Point_3< Kernel > &  a,
const Point_3< Kernel > &  b 
)

introduces the vector b-a.

template<typename Kernel >
CGAL::Vector_3< Kernel >::Vector_3 ( const Segment_3< Kernel > &  s)

introduces the vector s.target()-s.source().

template<typename Kernel >
CGAL::Vector_3< Kernel >::Vector_3 ( const Ray_3< Kernel > &  r)

introduces a vector having the same direction as r.

template<typename Kernel >
CGAL::Vector_3< Kernel >::Vector_3 ( const Line_3< Kernel > &  l)

introduces a vector having the same direction as l.

template<typename Kernel >
CGAL::Vector_3< Kernel >::Vector_3 ( const Null_vector NULL_VECTOR)

introduces a null vector v.

template<typename Kernel >
CGAL::Vector_3< Kernel >::Vector_3 ( int  x,
int  y,
int  z 
)

introduces a vector v initialized to (x, y, z).

template<typename Kernel >
CGAL::Vector_3< Kernel >::Vector_3 ( double  x,
double  y,
double  z 
)

introduces a vector v initialized to `(x, y, z).

template<typename Kernel >
CGAL::Vector_3< Kernel >::Vector_3 ( const Kernel::RT hx,
const Kernel::RT hy,
const Kernel::RT hz,
const Kernel::RT hw = RT(1) 
)

introduces a vector v initialized to `(hx/hw, hy/hw, hz/hw).

template<typename Kernel >
CGAL::Vector_3< Kernel >::Vector_3 ( const Kernel::FT x,
const Kernel::FT y,
const Kernel::FT z 
)

introduces a vector v initialized to (x, y, z).

Member Function Documentation

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

returns the i'th Cartesian coordinate of v, starting at 0.

Precondition
\( 0\leq i \leq2\).
template<typename Kernel >
Cartesian_const_iterator CGAL::Vector_3< Kernel >::cartesian_begin ( ) const

returns an iterator to the Cartesian coordinates of v, starting with the 0th coordinate.

template<typename Kernel >
Cartesian_const_iterator CGAL::Vector_3< Kernel >::cartesian_end ( ) const

returns an off the end iterator to the Cartesian coordinates of v.

template<typename Kernel >
int CGAL::Vector_3< Kernel >::dimension ( ) const

returns the dimension (the constant 3).

template<typename Kernel >
Direction_3<Kernel> CGAL::Vector_3< Kernel >::direction ( ) const

returns the direction of v.

template<typename Kernel >
Kernel::RT CGAL::Vector_3< Kernel >::homogeneous ( int  i) const

returns the i'th homogeneous coordinate of v, starting with 0.

Precondition
\( 0\leq i \leq3\).
template<typename Kernel >
Kernel::RT CGAL::Vector_3< Kernel >::hw ( ) const

returns the homogenizing coordinate.

template<typename Kernel >
Kernel::RT CGAL::Vector_3< Kernel >::hx ( ) const

returns the homogeneous \( x\) coordinate.

template<typename Kernel >
Kernel::RT CGAL::Vector_3< Kernel >::hy ( ) const

returns the homogeneous \( y\) coordinate.

template<typename Kernel >
Kernel::RT CGAL::Vector_3< Kernel >::hz ( ) const

returns the homogeneous \( z\) coordinate.

template<typename Kernel >
bool CGAL::Vector_3< Kernel >::operator!= ( const Vector_3< Kernel > &  w) const

Test for inequality.

You can compare a vector with the NULL_VECTOR.

template<typename Kernel >
Kernel::FT CGAL::Vector_3< Kernel >::operator* ( const Vector_3< Kernel > &  w) const

returns the scalar product (= inner product) of the two vectors.

template<typename Kernel >
Vector_3<Kernel> CGAL::Vector_3< Kernel >::operator- ( ) const

Returns the opposite vector.

template<typename Kernel >
Vector_3<Kernel> CGAL::Vector_3< Kernel >::operator/ ( const Kernel::RT s) const

Division by a scalar.

template<typename Kernel >
bool CGAL::Vector_3< Kernel >::operator== ( const Vector_3< Kernel > &  w) const

Test for equality: two vectors are equal, iff their \( x\), \( y\) and \( z\) coordinates are equal.

You can compare a vector with the NULL_VECTOR.

template<typename Kernel >
Kernel::FT CGAL::Vector_3< Kernel >::operator[] ( int  i) const

returns cartesian(i).

Precondition
\( 0\leq i \leq2\).
template<typename Kernel >
Kernel::FT CGAL::Vector_3< Kernel >::squared_length ( ) const

returns the squared length of v.

template<typename Kernel >
Vector_3<Kernel> CGAL::Vector_3< Kernel >::transform ( const Aff_transformation_3< Kernel > &  t) const

returns the vector obtained by applying t on v.

template<typename Kernel >
Kernel::FT CGAL::Vector_3< Kernel >::x ( ) const

returns the x-coordinate of v, that is hx()/hw().

template<typename Kernel >
Kernel::FT CGAL::Vector_3< Kernel >::y ( ) const

returns the y-coordinate of v, that is hy()/hw().

template<typename Kernel >
Kernel::FT CGAL::Vector_3< Kernel >::z ( ) const

returns the z coordinate of v, that is hz()/hw().