CGAL 6.1.2 - 2D and 3D Linear Geometry Kernel: CGAL::Vector_3< Kernel > Class Template Reference

CGAL 6.1.2 - 2D and 3D Linear Geometry Kernel

Loading...
Searching...
No Matches
List of all members | Public Member Functions
CGAL::Vector_3< Kernel > Class Template Reference
Reference Manual » 3D Kernel Objects

`#include <CGAL/Vector_3.h>`

## Definition

template<typename Kernel>
class CGAL::Vector_3< Kernel >

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.

Is model of
  `Kernel::Vector_3`
  `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable`

See also
  `CGAL::cross_product()`
  `CGAL::determinant()`

## Public Member Functions
Kernel::FT | squared_length () const
| returns the squared length of `v`.

## Types
typedef unspecified_type | Cartesian_const_iterator
| An iterator for enumerating the Cartesian coordinates of a vector.

## Creation
| Vector_3 (const Point_3< Kernel > &a, const Point_3< Kernel > &b)
| introduces the vector `b-a`.
| Vector_3 (const Segment_3< Kernel > &s)
| introduces the vector `s.target()-s.source()`.
| Vector_3 (const Ray_3< Kernel > &r)
| introduces a vector having the same direction as `r`.
| Vector_3 (const Line_3< Kernel > &l)
| introduces a vector having the same direction as `l`.
| Vector_3 (const Null_vector &NULL_VECTOR)
| introduces a null vector `v`.
| Vector_3 (int x, int y, int z)
| introduces a vector `v` initialized to `(x, y, z)`.
| Vector_3 (double x, double y, double z)
| introduces a vector `v` initialized to `(x, y, z)`.
| 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)`.
| Vector_3 (const Kernel::FT &x, const Kernel::FT &y, const Kernel::FT &z)
| introduces a vector `v` initialized to `(x, y, z)`.

## 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 lose information with the homogeneous representation, because the `FieldNumberType` is a quotient.
Kernel::RT | hx () const
| returns the homogeneous \( x\) coordinate.
Kernel::RT | hy () const
| returns the homogeneous \( y\) coordinate.
Kernel::RT | hz () const
| returns the homogeneous \( z\) coordinate.
Kernel::RT | hw () const
| returns the homogenizing coordinate.
Kernel::FT | x () const
| returns the `x`-coordinate of `v`, that is `hx()`/`hw()`.
Kernel::FT | y () const
| returns the `y`-coordinate of `v`, that is `hy()`/`hw()`.
Kernel::FT | z () const
| returns the `z` coordinate of `v`, that is `hz()`/`hw()`.

## 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`.
Kernel::FT | cartesian (int i) const
| returns the i-th Cartesian coordinate of `v`.
Kernel::FT | operator[] (int i) const
| returns `cartesian(i)`.
Cartesian_const_iterator | cartesian_begin () const
| returns an iterator to the Cartesian coordinates of `v`, starting with the 0th coordinate.
Cartesian_const_iterator | cartesian_end () const
| returns an off the end iterator to the Cartesian coordinates of `v`.
int | dimension () const
| returns the dimension (the constant 3).
Vector_3< Kernel > | transform (const Aff_transformation_3< Kernel > &t) const
| returns the vector obtained by applying `t` on `v`.
Direction_3< Kernel > | direction () const
| returns the direction of `v`.

## Operators
bool | operator== (const Vector_3< Kernel > &w) const
| Test for equality: two vectors are equal, iff their \( x\), \( y\) and \( z\) coordinates are equal.
bool | operator!= (const Vector_3< Kernel > &w) const
| Test for inequality.
Vector_3< Kernel > | operator+ (const Vector_3< Kernel > &w) const
| Addition.
Vector_3< Kernel > & | operator+= (const Vector_3< Kernel > &w)
| Addition.
Vector_3< Kernel > | operator- (const Vector_3< Kernel > &w) const
| Subtraction.
Vector_3< Kernel > & | operator-= (const Vector_3< Kernel > &w)
| Subtraction.
Vector_3< Kernel > | operator- () const
| Returns the opposite vector.
Vector_3< Kernel > | operator/ (const Kernel::RT &s) const
| Division by a scalar.
Vector_3< Kernel > & | operator/= (const Kernel::RT &s)
| Division by a scalar.
Kernel::FT | operator* (const Vector_3< Kernel > &w) const
| returns the scalar product (= inner product) of the two vectors.
Vector_3< Kernel > & | operator*= (const Kernel::FT &s)
| Multiplication by a scalar.
Vector_3< Kernel > | operator* (const Vector_3< Kernel > &v, const Kernel::RT &s)
| Multiplication with a scalar from the right.
Vector_3< Kernel > | operator* (const Vector_3< Kernel > &v, const Kernel::FT &s)
| Multiplication with a scalar from the right.
Vector_3< Kernel > | operator* (const Kernel::RT &s, const Vector_3< Kernel > &v)
| Multiplication with a scalar from the left.
Vector_3< Kernel > | operator* (const Kernel::FT &s, const Vector_3< Kernel > &v)
| Multiplication with a scalar from the left.

## Constructor & Destructor Documentation

## ◆ Vector_3() [1/3]

template<typename Kernel >

CGAL::Vector_3< Kernel >::Vector_3 | ( | const Null_vector & | NULL_VECTOR | ) |

introduces a null vector `v`.

Exactness
  This construction is trivial and therefore always exact in `Exact_predicates_inexact_constructions_kernel`.

## ◆ Vector_3() [2/3]

template<typename Kernel >

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

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

Exactness
  This construction is trivial and therefore always exact in `Exact_predicates_inexact_constructions_kernel`.

## ◆ Vector_3() [3/3]

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

Exactness
  This construction is trivial and therefore always exact in `Exact_predicates_inexact_constructions_kernel`.

## Member Function Documentation

## ◆ cartesian()

template<typename Kernel >

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

returns the i-th Cartesian coordinate of `v`.

Precondition
  `0 <= i <= 2`

Exactness
  This construction is trivial and therefore always exact in `Exact_predicates_inexact_constructions_kernel`.

## ◆ direction()

template<typename Kernel >

Direction_3< Kernel > CGAL::Vector_3< Kernel >::direction | ( |  | ) | const

returns the direction of `v`.

Exactness
  This construction is trivial and therefore always exact in `Exact_predicates_inexact_constructions_kernel`.

## ◆ homogeneous()

template<typename Kernel >

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

returns the i-th homogeneous coordinate of `v`.

Precondition
  `0 <= i <= 3`.

## ◆ operator!=()

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`.

## ◆ operator-()

template<typename Kernel >

Vector_3< Kernel > CGAL::Vector_3< Kernel >::operator- | ( |  | ) | const

Returns the opposite vector.

Exactness
  This construction is trivial and therefore always exact in `Exact_predicates_inexact_constructions_kernel`.

## ◆ operator==()

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`.

## ◆ operator[]()

template<typename Kernel >

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

returns `cartesian(i)`.

Precondition
  `0 <= i <= 2`

Exactness
  This construction is trivial and therefore always exact in `Exact_predicates_inexact_constructions_kernel`.

## ◆ x()

template<typename Kernel >

Kernel::FT CGAL::Vector_3< Kernel >::x | ( |  | ) | const

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

Exactness
  This construction is trivial and therefore always exact in `Exact_predicates_inexact_constructions_kernel`.

## ◆ y()

template<typename Kernel >

Kernel::FT CGAL::Vector_3< Kernel >::y | ( |  | ) | const

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

Exactness
  This construction is trivial and therefore always exact in `Exact_predicates_inexact_constructions_kernel`.

## ◆ z()

template<typename Kernel >

Kernel::FT CGAL::Vector_3< Kernel >::z | ( |  | ) | const

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

Exactness
  This construction is trivial and therefore always exact in `Exact_predicates_inexact_constructions_kernel`.