Geogram Version 1.10.2
A programming library of geometric algorithms
Loading...
Searching...
No Matches
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.
typedef T value_type
 The type of the vector coordinates.

Public Member Functions

 vecng ()
 Default vector constructor.
 vecng (const T &x_in, const T &y_in, const T &z_in, const T &w_in)
 Constructs a vector from coordinates.
 vecng (T &&x_in, T &&y_in, T &&z_in, T &&w_in)
 Constructs a vector from coordinates.
 vecng (const vecng< 4, T > &rhs)=default
 vecng (vecng< 4, T > &&rhs)=default
template<class T2>
 vecng (const vecng< dim, T2 > &v)
 Constructs a vector by copy.
template<class T2>
 vecng (const T2 *v)
 Constructs a vector from an array.
 vecng (const std::initializer_list< T > &Vi)
vecng< 4, T > & operator= (const vecng< 4, T > &rhs)=default
vecng< 4, T > & operator= (vecng< 4, T > &&rhs)=default
template<typename U>
 vecng (vecng< 1, U > const &v)
template<typename X, typename Y, typename Z, typename W>
 vecng (X _x, Y _y, Z _z, W _w)
template<typename X, typename Y, typename Z, typename W>
 vecng (const vecng< 1, X > &_x, Y _y, Z _z, W _w)
template<typename X, typename Y, typename Z, typename W>
 vecng (X _x, const vecng< 1, Y > &_y, Z _z, W _w)
template<typename X, typename Y, typename Z, typename W>
 vecng (const vecng< 1, X > &_x, const vecng< 1, Y > &_y, Z _z, W _w)
template<typename X, typename Y, typename Z, typename W>
 vecng (X _x, Y _y, const vecng< 1, Z > &_z, W _w)
template<typename X, typename Y, typename Z, typename W>
 vecng (const vecng< 1, X > &_x, Y _y, const vecng< 1, Z > &_z, W _w)
template<typename X, typename Y, typename Z, typename W>
 vecng (X _x, const vecng< 1, Y > &_y, const vecng< 1, Z > &_z, W _w)
template<typename X, typename Y, typename Z, typename W>
 vecng (const vecng< 1, X > &_x, const vecng< 1, Y > &_y, const vecng< 1, Z > &_z, W _w)
template<typename X, typename Y, typename Z, typename W>
 vecng (const vecng< 1, X > &_x, Y _y, Z _z, const vecng< 1, W > &_w)
template<typename X, typename Y, typename Z, typename W>
 vecng (X _x, const vecng< 1, Y > &_y, Z _z, const vecng< 1, W > &_w)
template<typename X, typename Y, typename Z, typename W>
 vecng (const vecng< 1, X > &_x, const vecng< 1, Y > &_y, Z _z, const vecng< 1, W > &_w)
template<typename X, typename Y, typename Z, typename W>
 vecng (X _x, Y _y, const vecng< 1, Z > &_z, const vecng< 1, W > &_w)
template<typename X, typename Y, typename Z, typename W>
 vecng (const vecng< 1, X > &_x, Y _y, const vecng< 1, Z > &_z, const vecng< 1, W > &_w)
template<typename X, typename Y, typename Z, typename W>
 vecng (X _x, const vecng< 1, Y > &_y, const vecng< 1, Z > &_z, const vecng< 1, W > &_w)
template<typename X, typename Y, typename Z, typename W>
 vecng (const vecng< 1, X > &_x, const vecng< 1, Y > &_y, const vecng< 1, Z > &_z, const vecng< 1, W > &_w)
template<typename A, typename B, typename C>
 vecng (const vecng< 2, A > &_xy, B _z, C _w)
template<typename A, typename B, typename C>
 vecng (const vecng< 2, A > &_xy, const vecng< 1, B > &_z, C _w)
template<typename A, typename B, typename C>
 vecng (const vecng< 2, A > &_xy, B _z, const vecng< 1, C > &_w)
template<typename A, typename B, typename C>
 vecng (const vecng< 2, A > &_xy, const vecng< 1, B > &_z, const vecng< 1, C > &_w)
template<typename A, typename B, typename C>
 vecng (A _x, const vecng< 2, B > &_yz, C _w)
template<typename A, typename B, typename C>
 vecng (const vecng< 1, A > &_x, const vecng< 2, B > &_yz, C _w)
template<typename A, typename B, typename C>
 vecng (A _x, const vecng< 2, B > &_yz, const vecng< 1, C > &_w)
template<typename A, typename B, typename C>
 vecng (const vecng< 1, A > &_x, const vecng< 2, B > &_yz, const vecng< 1, C > &_w)
template<typename A, typename B, typename C>
 vecng (A _x, B _y, const vecng< 2, C > &_zw)
template<typename A, typename B, typename C>
 vecng (const vecng< 1, A > &_x, B _y, const vecng< 2, C > &_zw)
template<typename A, typename B, typename C>
 vecng (A _x, const vecng< 1, B > &_y, const vecng< 2, C > &_zw)
template<typename A, typename B, typename C>
 vecng (const vecng< 1, A > &_x, const vecng< 1, B > &_y, const vecng< 2, C > &_zw)
template<typename A, typename B>
 vecng (const vecng< 3, A > &_xyz, B _w)
template<typename A, typename B>
 vecng (const vecng< 3, A > &_xyz, const vecng< 1, B > &_w)
template<typename A, typename B>
 vecng (A _x, const vecng< 3, B > &_yzw)
template<typename A, typename B>
 vecng (const vecng< 1, A > &_x, const vecng< 3, B > &_yzw)
template<typename A, typename B>
 vecng (const vecng< 2, A > &_xy, const vecng< 2, B > &_zw)
T length2 () const
 Gets the squared length of the vector.
T length () const
 Gets the length of the vector.
T distance2 (const vector_type &v) const
T distance (const vector_type &v) const
index_t dimension () const
 Gets the vector dimension.
vector_type & operator+= (const vector_type &v)
vector_type & operator-= (const vector_type &v)
template<class T2>
vector_type & operator*= (T2 s)
 Multiplies by a scalar in place.
template<class T2>
vector_type & operator/= (T2 s)
 Divides by a scalar in place.
vector_type operator+ (const vector_type &v) const
vector_type operator- (const vector_type &v) const
template<class T2>
vector_type operator/ (T2 s) const
 Divides a vector by a scalar.
vector_type operator- () const
 Negates a vector.
T * data ()
 Gets modifiable vector data.
const T * data () const
 Gets non-modifiable vector data.
T & operator[] (index_t i)
 Gets a modifiable vector coordinate.
const T & operator[] (index_t i) const
 Gets a non-modifiable vector coordinate.

Public Attributes

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

Static Public Attributes

static constexpr index_t dim = 4
 The dimension of the vector.

(Note that these are not member symbols.)

T dot (const vecng< DIM, T > &v1, const vecng< DIM, T > &v2)
 Computes the dot product of 2 vectors.
vecng< DIM, T > operator* (T2 s, const vecng< DIM, T > &v)
 Multiplies a scalar by a vector.
vecng< DIM, T > operator* (const vecng< DIM, T > &v, T2 s)
 Multiplies a scalar by a vector.
T length (const vecng< DIM, T > &v)
 Gets the norm of a vector.
T length2 (const vecng< DIM, T > &v)
 Gets the square norm of a vector.
T distance2 (const vecng< DIM, T > &v1, const vecng< DIM, T > &v2)
 Gets the square distance between 2 vectors.
T distance (const vecng< DIM, T > &v1, const vecng< DIM, T > &v2)
 Gets the distance between 2 vectors.
GEO_NODISCARD vecng< DIM, T > normalize (const vecng< DIM, T > &v)
 Normalizes a vector.
vecng< DIM, T > mix (const vecng< DIM, T > &v1, const vecng< DIM, T > &v2, T s)
 Computes a weighted barycenter.
T dot (const vecng< 2, T > &v1, const vecng< 2, T > &v2)
 Computes the dot product of 2 vectors.
T det (const vecng< 2, T > &v1, const vecng< 2, T > &v2)
 Computes the determinant of 2 vectors.
vecng< 2, T > operator* (T2 s, const vecng< 2, T > &v)
 Multiplies a scalar by a vector.
vecng< 2, T > operator* (const vecng< 2, T > &v, T2 s)
 Multiplies a scalar by a vector.
vecng< 3, T > cross (const vecng< 3, T > &v1, const vecng< 3, T > &v2)
 Computes the cross product of 2 vectors.
vecng< 3, T > operator* (T2 s, const vecng< 3, T > &v)
 Multiplies a scalar by a vector.
vecng< 3, T > operator* (const vecng< 3, T > &v, T2 s)
 Multiplies a scalar by a vector.
T dot (const vecng< 4, T > &v1, const vecng< 4, T > &v2)
 Computes the dot product of 2 vectors.
vecng< 4, T > operator* (T2 s, const vecng< 4, T > &v)
 Multiplies a scalar by a vector.
vecng< 4, T > operator* (const vecng< 4, T > &v, T2 s)
 Multiplies a scalar by a vector.
std::ostream & operator<< (std::ostream &out, const GEO::vecng< DIM, T > &v)
 Writes a vector to a stream.
std::istream & operator>> (std::istream &in, GEO::vecng< DIM, T > &v)
 Reads a vector from a stream.

Detailed Description

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

Specialization of class vecn3 for DIM == 4.

See also
vecng

Definition at line 1055 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 1064 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 1061 of file vecg.h.

Constructor & Destructor Documentation

◆ vecng() [1/39]

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

Default vector constructor.

All coordinates are initialized to 0 (zero).

Definition at line 1067 of file vecg.h.

◆ vecng() [2/39]

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

Constructs a vector from coordinates.

Parameters
[in]x_in,y_in,z_in,w_inreferences to vector coordinates

Definition at line 1078 of file vecg.h.

◆ vecng() [3/39]

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

Constructs a vector from coordinates.

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

Definition at line 1089 of file vecg.h.

◆ vecng() [4/39]

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 1101 of file vecg.h.

◆ vecng() [5/39]

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 1110 of file vecg.h.

◆ vecng() [6/39]

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

Definition at line 1118 of file vecg.h.

◆ vecng() [7/39]

template<typename T>
template<typename U>
GEO::vecng< 4, T >::vecng ( vecng< 1, U > const & v)
explicit

Definition at line 1494 of file vecg.h.

◆ vecng() [8/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( X _x,
Y _y,
Z _z,
W _w )

Definition at line 1503 of file vecg.h.

◆ vecng() [9/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( const vecng< 1, X > & _x,
Y _y,
Z _z,
W _w )

Definition at line 1512 of file vecg.h.

◆ vecng() [10/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( X _x,
const vecng< 1, Y > & _y,
Z _z,
W _w )

Definition at line 1521 of file vecg.h.

◆ vecng() [11/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( const vecng< 1, X > & _x,
const vecng< 1, Y > & _y,
Z _z,
W _w )

Definition at line 1530 of file vecg.h.

◆ vecng() [12/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( X _x,
Y _y,
const vecng< 1, Z > & _z,
W _w )

Definition at line 1539 of file vecg.h.

◆ vecng() [13/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( const vecng< 1, X > & _x,
Y _y,
const vecng< 1, Z > & _z,
W _w )

Definition at line 1548 of file vecg.h.

◆ vecng() [14/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( X _x,
const vecng< 1, Y > & _y,
const vecng< 1, Z > & _z,
W _w )

Definition at line 1557 of file vecg.h.

◆ vecng() [15/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( const vecng< 1, X > & _x,
const vecng< 1, Y > & _y,
const vecng< 1, Z > & _z,
W _w )

Definition at line 1566 of file vecg.h.

◆ vecng() [16/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( const vecng< 1, X > & _x,
Y _y,
Z _z,
const vecng< 1, W > & _w )

Definition at line 1577 of file vecg.h.

◆ vecng() [17/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( X _x,
const vecng< 1, Y > & _y,
Z _z,
const vecng< 1, W > & _w )

Definition at line 1587 of file vecg.h.

◆ vecng() [18/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( const vecng< 1, X > & _x,
const vecng< 1, Y > & _y,
Z _z,
const vecng< 1, W > & _w )

Definition at line 1597 of file vecg.h.

◆ vecng() [19/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( X _x,
Y _y,
const vecng< 1, Z > & _z,
const vecng< 1, W > & _w )

Definition at line 1608 of file vecg.h.

◆ vecng() [20/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( const vecng< 1, X > & _x,
Y _y,
const vecng< 1, Z > & _z,
const vecng< 1, W > & _w )

Definition at line 1617 of file vecg.h.

◆ vecng() [21/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( X _x,
const vecng< 1, Y > & _y,
const vecng< 1, Z > & _z,
const vecng< 1, W > & _w )

Definition at line 1628 of file vecg.h.

◆ vecng() [22/39]

template<typename T>
template<typename X, typename Y, typename Z, typename W>
GEO::vecng< 4, T >::vecng ( const vecng< 1, X > & _x,
const vecng< 1, Y > & _y,
const vecng< 1, Z > & _z,
const vecng< 1, W > & _w )

Definition at line 1639 of file vecg.h.

◆ vecng() [23/39]

template<typename T>
template<typename A, typename B, typename C>
GEO::vecng< 4, T >::vecng ( const vecng< 2, A > & _xy,
B _z,
C _w )

Definition at line 1652 of file vecg.h.

◆ vecng() [24/39]

template<typename T>
template<typename A, typename B, typename C>
GEO::vecng< 4, T >::vecng ( const vecng< 2, A > & _xy,
const vecng< 1, B > & _z,
C _w )

Definition at line 1661 of file vecg.h.

◆ vecng() [25/39]

template<typename T>
template<typename A, typename B, typename C>
GEO::vecng< 4, T >::vecng ( const vecng< 2, A > & _xy,
B _z,
const vecng< 1, C > & _w )

Definition at line 1670 of file vecg.h.

◆ vecng() [26/39]

template<typename T>
template<typename A, typename B, typename C>
GEO::vecng< 4, T >::vecng ( const vecng< 2, A > & _xy,
const vecng< 1, B > & _z,
const vecng< 1, C > & _w )

Definition at line 1679 of file vecg.h.

◆ vecng() [27/39]

template<typename T>
template<typename A, typename B, typename C>
GEO::vecng< 4, T >::vecng ( A _x,
const vecng< 2, B > & _yz,
C _w )

Definition at line 1689 of file vecg.h.

◆ vecng() [28/39]

template<typename T>
template<typename A, typename B, typename C>
GEO::vecng< 4, T >::vecng ( const vecng< 1, A > & _x,
const vecng< 2, B > & _yz,
C _w )

Definition at line 1698 of file vecg.h.

◆ vecng() [29/39]

template<typename T>
template<typename A, typename B, typename C>
GEO::vecng< 4, T >::vecng ( A _x,
const vecng< 2, B > & _yz,
const vecng< 1, C > & _w )

Definition at line 1707 of file vecg.h.

◆ vecng() [30/39]

template<typename T>
template<typename A, typename B, typename C>
GEO::vecng< 4, T >::vecng ( const vecng< 1, A > & _x,
const vecng< 2, B > & _yz,
const vecng< 1, C > & _w )

Definition at line 1716 of file vecg.h.

◆ vecng() [31/39]

template<typename T>
template<typename A, typename B, typename C>
GEO::vecng< 4, T >::vecng ( A _x,
B _y,
const vecng< 2, C > & _zw )

Definition at line 1726 of file vecg.h.

◆ vecng() [32/39]

template<typename T>
template<typename A, typename B, typename C>
GEO::vecng< 4, T >::vecng ( const vecng< 1, A > & _x,
B _y,
const vecng< 2, C > & _zw )

Definition at line 1735 of file vecg.h.

◆ vecng() [33/39]

template<typename T>
template<typename A, typename B, typename C>
GEO::vecng< 4, T >::vecng ( A _x,
const vecng< 1, B > & _y,
const vecng< 2, C > & _zw )

Definition at line 1744 of file vecg.h.

◆ vecng() [34/39]

template<typename T>
template<typename A, typename B, typename C>
GEO::vecng< 4, T >::vecng ( const vecng< 1, A > & _x,
const vecng< 1, B > & _y,
const vecng< 2, C > & _zw )

Definition at line 1753 of file vecg.h.

◆ vecng() [35/39]

template<typename T>
template<typename A, typename B>
GEO::vecng< 4, T >::vecng ( const vecng< 3, A > & _xyz,
B _w )

Definition at line 1763 of file vecg.h.

◆ vecng() [36/39]

template<typename T>
template<typename A, typename B>
GEO::vecng< 4, T >::vecng ( const vecng< 3, A > & _xyz,
const vecng< 1, B > & _w )

Definition at line 1772 of file vecg.h.

◆ vecng() [37/39]

template<typename T>
template<typename A, typename B>
GEO::vecng< 4, T >::vecng ( A _x,
const vecng< 3, B > & _yzw )

Definition at line 1781 of file vecg.h.

◆ vecng() [38/39]

template<typename T>
template<typename A, typename B>
GEO::vecng< 4, T >::vecng ( const vecng< 1, A > & _x,
const vecng< 3, B > & _yzw )

Definition at line 1790 of file vecg.h.

◆ vecng() [39/39]

template<typename T>
template<typename A, typename B>
GEO::vecng< 4, T >::vecng ( const vecng< 2, A > & _xy,
const vecng< 2, B > & _zw )

Definition at line 1799 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 1315 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 1320 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 1251 of file vecg.h.

◆ distance()

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

Definition at line 1246 of file vecg.h.

◆ distance2()

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

Definition at line 1237 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 1232 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 1227 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 1275 of file vecg.h.

◆ operator+()

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

Definition at line 1294 of file vecg.h.

◆ operator+=()

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

Definition at line 1256 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 1310 of file vecg.h.

◆ operator-() [2/2]

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

Definition at line 1299 of file vecg.h.

◆ operator-=()

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

Definition at line 1265 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 1305 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 1285 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 1325 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 1331 of file vecg.h.

◆ cross()

vecng< 3, T > cross ( const vecng< 3, T > & v1,
const vecng< 3, T > & v2 )
related

Computes the cross product of 2 vectors.

Parameters
[in]v1the first vector
[in]v2the second vector
Returns
the cross product (v1 x v2)

Definition at line 1009 of file vecg.h.

◆ det()

T det ( const vecng< 2, T > & v1,
const vecng< 2, T > & v2 )
related

Computes the determinant of 2 vectors.

Parameters
[in]v1the first vector
[in]v2the second vector
Returns
the value of the determinant

Definition at line 732 of file vecg.h.

◆ distance()

T distance ( const vecng< DIM, T > & v1,
const vecng< DIM, T > & v2 )
related

Gets the distance between 2 vectors.

Parameters
[in]v1the first vector
[in]v2the second vector
Returns
the distance between v1 and v2.
See also
vecng::distance()

Definition at line 486 of file vecg.h.

◆ distance2()

T distance2 ( const vecng< DIM, T > & v1,
const vecng< DIM, T > & v2 )
related

Gets the square distance between 2 vectors.

Parameters
[in]v1the first vector
[in]v2the second vector
Returns
the square distance between v1 and v2.
See also
vecng::distance2()

Definition at line 471 of file vecg.h.

◆ dot() [1/3]

T dot ( const vecng< 2, T > & v1,
const vecng< 2, T > & v2 )
related

Computes the dot product of 2 vectors.

Parameters
[in]v1the first vector
[in]v2the second vector
Returns
the dot product (v1 . v2)

Definition at line 718 of file vecg.h.

◆ dot() [2/3]

T dot ( const vecng< 4, T > & v1,
const vecng< 4, T > & v2 )
related

Computes the dot product of 2 vectors.

Parameters
[in]v1the first vector
[in]v2the second vector
Returns
the dot product (v1 . v2)

Definition at line 1351 of file vecg.h.

◆ dot() [3/3]

T dot ( const vecng< DIM, T > & v1,
const vecng< DIM, T > & v2 )
related

Computes the dot product of 2 vectors.

Parameters
[in]v1the first vector
[in]v2the second vector
Returns
the dot product (v1 . v2)

Definition at line 375 of file vecg.h.

◆ length()

T length ( const vecng< DIM, T > & v)
related

Gets the norm of a vector.

Parameters
[in]va vector
Returns
the norm of vector v
See also
vecng::length()

Definition at line 446 of file vecg.h.

◆ length2()

T length2 ( const vecng< DIM, T > & v)
related

Gets the square norm of a vector.

Parameters
[in]va vector
Returns
the square norm of vector v
See also
vecng::length2()

Definition at line 458 of file vecg.h.

◆ mix()

vecng< DIM, T > mix ( const vecng< DIM, T > & v1,
const vecng< DIM, T > & v2,
T s )
related

Computes a weighted barycenter.

Computes the barycenter of v1 and v2 weighted by value 1 - s and s.

Parameters
[in]v1the first vector
[in]v2the second vector
[in]sthe weight value
Returns
the barycenter (1 - s) * v1 + s * v2

Definition at line 523 of file vecg.h.

◆ normalize()

GEO_NODISCARD vecng< DIM, T > normalize ( const vecng< DIM, T > & v)
related

Normalizes a vector.

Returns a normalized vector constructed by dividing coordinates of vector v by it norm. If the norm is 0, then the result is undefined.

Parameters
[in]va vector
Returns
the normalized vector

Definition at line 502 of file vecg.h.

◆ operator*() [1/8]

vecng< 2, T > operator* ( const vecng< 2, T > & v,
T2 s )
related

Multiplies a scalar by a vector.

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]vthe vector to multiply
[in]sa value of type T2
Template Parameters
T2the type of value s
Returns
the result vector (s * v)

Definition at line 759 of file vecg.h.

◆ operator*() [2/8]

vecng< 3, T > operator* ( const vecng< 3, T > & v,
T2 s )
related

Multiplies a scalar by a vector.

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]vthe vector to multiply
[in]sa value of type T2
Template Parameters
T2the type of value s
Returns
the result vector (s * v)

Definition at line 1040 of file vecg.h.

◆ operator*() [3/8]

vecng< 4, T > operator* ( const vecng< 4, T > & v,
T2 s )
related

Multiplies a scalar by a vector.

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]vthe vector to multiply
[in]sa value of type T2
Template Parameters
T2the type of value s
Returns
the result vector (s * v)

Definition at line 1378 of file vecg.h.

◆ operator*() [4/8]

vecng< DIM, T > operator* ( const vecng< DIM, T > & v,
T2 s )
related

Multiplies a scalar by a vector.

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]vthe vector to multiply
[in]sa value of type T2
Template Parameters
T2the type of value s
Returns
the result vector (s * v)

Definition at line 425 of file vecg.h.

◆ operator*() [5/8]

vecng< 2, T > operator* ( T2 s,
const vecng< 2, T > & v )
related

Multiplies a scalar by a vector.

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
[in]vthe vector to multiply
Template Parameters
T2the type of value s
Returns
the result vector (s * v)

Definition at line 746 of file vecg.h.

◆ operator*() [6/8]

vecng< 3, T > operator* ( T2 s,
const vecng< 3, T > & v )
related

Multiplies a scalar by a vector.

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
[in]vthe vector to multiply
Template Parameters
T2the type of value s
Returns
the result vector (s * v)

Definition at line 1027 of file vecg.h.

◆ operator*() [7/8]

vecng< 4, T > operator* ( T2 s,
const vecng< 4, T > & v )
related

Multiplies a scalar by a vector.

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
[in]vthe vector to multiply
Template Parameters
T2the type of value s
Returns
the result vector (s * v)

Definition at line 1365 of file vecg.h.

◆ operator*() [8/8]

vecng< DIM, T > operator* ( T2 s,
const vecng< DIM, T > & v )
related

Multiplies a scalar by a vector.

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
[in]vthe vector to multiply
Template Parameters
T2the type of value s
Returns
the result vector (s * v)

Definition at line 400 of file vecg.h.

◆ operator<<()

std::ostream & operator<< ( std::ostream & out,
const GEO::vecng< DIM, T > & v )
related

Writes a vector to a stream.

This writes the coordinates of vector v separated by a space character to the output stream out.

Parameters
[in]outthe output stream
[in]vthe vector to write
Returns
a reference to the output stream out

Definition at line 1396 of file vecg.h.

◆ operator>>()

std::istream & operator>> ( std::istream & in,
GEO::vecng< DIM, T > & v )
related

Reads a vector from a stream.

This reads DIM coordinates from the input stream in and stores them in vector v. Understands both "x y z", "[x, y, z]" and "{x, y, z}" formats.

Parameters
[in]inthe input stream
[out]vthe vector to read
Returns
a reference to the input stream in

Definition at line 1418 of file vecg.h.

Member Data Documentation

◆ dim

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

The dimension of the vector.

Definition at line 1058 of file vecg.h.

◆ w

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

Vector w coordinate.

Definition at line 1343 of file vecg.h.

◆ x

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

Vector x coordinate.

Definition at line 1337 of file vecg.h.

◆ y

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

Vector y coordinate.

Definition at line 1339 of file vecg.h.

◆ z

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

Vector z coordinate.

Definition at line 1341 of file vecg.h.


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