Geogram  Version 1.9.1-rc
A programming library of geometric algorithms
GEO::vecng< 4, T > Class Template Reference

Specialization of class vecn3 for DIM == 4. More...

#include <geogram/basic/vecg.h>

Inheritance diagram for GEO::vecng< 4, T >:
GEO::GenColor< T >

Public Types

typedef vecng< dim, T > vector_type
 This vector type. More...
 
typedef T value_type
 The type of the vector coordinates. More...
 

Public Member Functions

 vecng ()
 Default vector constructor. More...
 
 vecng (T x_in, T y_in, T z_in, T w_in)
 Constructs a vector from coordinates. More...
 
template<class T2 >
 vecng (const vecng< dim, T2 > &v)
 Constructs a vector by copy. More...
 
template<class T2 >
 vecng (const T2 *v)
 Constructs a vector from an array. More...
 
 vecng (const std::initializer_list< T > &Vi)
 
length2 () const
 Gets the squared length of the vector. More...
 
length () const
 Gets the length of the vector. More...
 
distance2 (const vector_type &v) const
 Gets the squared distance to a vector. More...
 
distance (const vector_type &v) const
 Gets the distance to a vector. More...
 
index_t dimension () const
 Gets the vector dimension. More...
 
vector_typeoperator+= (const vector_type &v)
 Adds a vector in place. More...
 
vector_typeoperator-= (const vector_type &v)
 Subtracts a vector in place. More...
 
template<class T2 >
vector_typeoperator*= (T2 s)
 Multiplies by a scalar in place. More...
 
template<class T2 >
vector_typeoperator/= (T2 s)
 Divides by a scalar in place. More...
 
vector_type operator+ (const vector_type &v) const
 Adds 2 vectors. More...
 
vector_type operator- (const vector_type &v) const
 Subtracts 2 vectors. More...
 
template<class T2 >
vector_type operator* (T2 s) const
 Multiplies a vector by a scalar. More...
 
template<class T2 >
vector_type operator/ (T2 s) const
 Divides a vector by a scalar. More...
 
vector_type operator- () const
 Negates a vector. More...
 
T * data ()
 Gets modifiable vector data. More...
 
const T * data () const
 Gets non-modifiable vector data. More...
 
T & operator[] (index_t i)
 Gets a modifiable vector coordinate. More...
 
const T & operator[] (index_t i) const
 Gets a non-modifiable vector coordinate. More...
 

Public Attributes

x
 Vector x coordinate.
 
y
 Vector y coordinate.
 
z
 Vector z coordinate.
 
w
 Vector w coordinate.
 

Static Public Attributes

static const index_t dim = 4
 The dimension of the vector. More...
 

Detailed Description

template<class T>
class GEO::vecng< 4, T >

Specialization of class vecn3 for DIM == 4.

See also
vecng

Definition at line 958 of file vecg.h.

Member Typedef Documentation

◆ value_type

template<class T >
typedef T GEO::vecng< 4, T >::value_type

The type of the vector coordinates.

Definition at line 967 of file vecg.h.

◆ vector_type

template<class T >
typedef vecng<dim, T> GEO::vecng< 4, T >::vector_type

This vector type.

Definition at line 964 of file vecg.h.

Constructor & Destructor Documentation

◆ vecng() [1/5]

template<class T >
GEO::vecng< 4, T >::vecng ( )
inline

Default vector constructor.

All coordinates are initialized to 0 (zero).

Definition at line 970 of file vecg.h.

◆ vecng() [2/5]

template<class T >
GEO::vecng< 4, T >::vecng ( x_in,
y_in,
z_in,
w_in 
)
inline

Constructs a vector from coordinates.

Parameters
[in]x_in,y_in,z_in,w_invector coordinates

Definition at line 981 of file vecg.h.

◆ vecng() [3/5]

template<class T >
template<class T2 >
GEO::vecng< 4, T >::vecng ( const vecng< dim, T2 > &  v)
inlineexplicit

Constructs a vector by copy.

This copies coordinates of vector v to this vector. The type T2 of the coordinates in v must be convertible to the type T of this vector.

Parameters
[in]van vector of same dimension with coordinates of type T2
Template Parameters
T2the type of coordinates in vector v

Definition at line 990 of file vecg.h.

◆ vecng() [4/5]

template<class T >
template<class T2 >
GEO::vecng< 4, T >::vecng ( const T2 *  v)
inlineexplicit

Constructs a vector from an array.

This copies coordinates the first DIM coordinates of array v to this vector. The type T2 of the coordinates in v must be convertible to the type T of this vector.

Parameters
[in]van array of values of type T2
Template Parameters
T2the type of coordinates in vector v

Definition at line 999 of file vecg.h.

◆ vecng() [5/5]

template<class T >
GEO::vecng< 4, T >::vecng ( const std::initializer_list< T > &  Vi)
inline

Definition at line 1007 of file vecg.h.

Member Function Documentation

◆ data() [1/2]

template<class T >
T* GEO::vecng< 4, T >::data ( )
inline

Gets modifiable vector data.

Returns
a pointer to the first element of the vector

Definition at line 1111 of file vecg.h.

◆ data() [2/2]

template<class T >
const T* GEO::vecng< 4, T >::data ( ) const
inline

Gets non-modifiable vector data.

Returns
a const pointer to the first element of the vector

Definition at line 1116 of file vecg.h.

◆ dimension()

template<class T >
index_t GEO::vecng< 4, T >::dimension ( ) const
inline

Gets the vector dimension.

Returns
the value of DIM

Definition at line 1041 of file vecg.h.

◆ distance()

template<class T >
T GEO::vecng< 4, T >::distance ( const vector_type v) const
inline

Gets the distance to a vector.

Parameters
[in]vanother vector
Returns
(v - this).length()

Definition at line 1036 of file vecg.h.

◆ distance2()

template<class T >
T GEO::vecng< 4, T >::distance2 ( const vector_type v) const
inline

Gets the squared distance to a vector.

Parameters
[in]vanother vector
Returns
(v - this).length2()

Definition at line 1027 of file vecg.h.

◆ length()

template<class T >
T GEO::vecng< 4, T >::length ( ) const
inline

Gets the length of the vector.

Definition at line 1022 of file vecg.h.

◆ length2()

template<class T >
T GEO::vecng< 4, T >::length2 ( ) const
inline

Gets the squared length of the vector.

Definition at line 1017 of file vecg.h.

◆ operator*()

template<class T >
template<class T2 >
vector_type GEO::vecng< 4, T >::operator* ( T2  s) const
inline

Multiplies a vector by a scalar.

Builds a vector by multipying this vector coordinates by value s. The type T2 of s must be convertible to the type T of this vector coordinates.

Parameters
[in]sa value of type T2
Template Parameters
T2the type of value s
Returns
the result vector (this * s)

Definition at line 1095 of file vecg.h.

◆ operator*=()

template<class T >
template<class T2 >
vector_type& GEO::vecng< 4, T >::operator*= ( T2  s)
inline

Multiplies by a scalar in place.

Multiplies this vector coordinates by value s. The type T2 of s must be convertible to the type T of this vector coordinates.

Parameters
[in]sa value of type T2
Template Parameters
T2the type of value s
Returns
a reference to this vector

Definition at line 1065 of file vecg.h.

◆ operator+()

template<class T >
vector_type GEO::vecng< 4, T >::operator+ ( const vector_type v) const
inline

Adds 2 vectors.

Builds a vector by adding coordinates of this vector and coordinates of vector v.

Parameters
[in]vanother vector
Returns
the result vector (this + v)

Definition at line 1084 of file vecg.h.

◆ operator+=()

template<class T >
vector_type& GEO::vecng< 4, T >::operator+= ( const vector_type v)
inline

Adds a vector in place.

Adds coordinates of vector v to this vector coordinates

Parameters
[in]vanother vector
Returns
a reference to this vector

Definition at line 1046 of file vecg.h.

◆ operator-() [1/2]

template<class T >
vector_type GEO::vecng< 4, T >::operator- ( ) const
inline

Negates a vector.

Builds a vector by negating coordinates of this vector.

Returns
the result vector (-this)

Definition at line 1106 of file vecg.h.

◆ operator-() [2/2]

template<class T >
vector_type GEO::vecng< 4, T >::operator- ( const vector_type v) const
inline

Subtracts 2 vectors.

Builds a vector by subtracting coordinates of vector v to coordinates of this vector.

Parameters
[in]vanother vector
Returns
the result vector (this - v)

Definition at line 1089 of file vecg.h.

◆ operator-=()

template<class T >
vector_type& GEO::vecng< 4, T >::operator-= ( const vector_type v)
inline

Subtracts a vector in place.

Subtracts coordinates of vector v from this vector coordinates

Parameters
[in]vanother vector
Returns
a reference to this vector

Definition at line 1055 of file vecg.h.

◆ operator/()

template<class T >
template<class T2 >
vector_type GEO::vecng< 4, T >::operator/ ( T2  s) const
inline

Divides a vector by a scalar.

Builds a vector by dividing this vector coordinates by value s. The type T2 of s must be convertible to the type T of this vector coordinates.

Parameters
[in]sa value of type T2
Template Parameters
T2the type of value s
Returns
the result vector (this / s)

Definition at line 1101 of file vecg.h.

◆ operator/=()

template<class T >
template<class T2 >
vector_type& GEO::vecng< 4, T >::operator/= ( T2  s)
inline

Divides by a scalar in place.

Divides this vector coordinates by value s. The type T2 of s must be convertible to the type T of this vector coordinates.

Parameters
[in]sa value of type T2
Template Parameters
T2the type of value s
Returns
a reference to this vector

Definition at line 1075 of file vecg.h.

◆ operator[]() [1/2]

template<class T >
T& GEO::vecng< 4, T >::operator[] ( index_t  i)
inline

Gets a modifiable vector coordinate.

Parameters
[in]iindex of the coordinate
Returns
a reference to coordinate at index i

Definition at line 1121 of file vecg.h.

◆ operator[]() [2/2]

template<class T >
const T& GEO::vecng< 4, T >::operator[] ( index_t  i) const
inline

Gets a non-modifiable vector coordinate.

Parameters
[in]iindex of the coordinate
Returns
a const reference to coordinate at index i

Definition at line 1127 of file vecg.h.

Member Data Documentation

◆ dim

template<class T >
const index_t GEO::vecng< 4, T >::dim = 4
static

The dimension of the vector.

Definition at line 961 of file vecg.h.


The documentation for this class was generated from the following file: