Jet  v1.3.3
Public Member Functions | Public Attributes | List of all members
jet::Vector< T, 4 > Class Template Referencefinal

4-D vector class. More...

#include <jet/vector4.h>

Public Member Functions

constexpr Vector ()
 Constructs default vector (0, 0, 0, 0). More...
 
constexpr Vector (T x_, T y_, T z_, T w_)
 Constructs vector with given parameters x_, y_, z_, and w_. More...
 
constexpr Vector (const Vector3< T > &v, T w_)
 Constructs vector with a 3-D vector (x, y, and z) and a scalar (w). More...
 
template<typename U >
 Vector (const std::initializer_list< U > &lst)
 Constructs vector with initializer list. More...
 
constexpr Vector (const Vector &v)
 Copy constructor. More...
 
void set (T s)
 Set both x, y, z, and w components to s. More...
 
void set (T x, T y, T z, T w)
 Set x, y, z, and w components with given parameters. More...
 
void set (const Vector< T, 3 > &pt, T z)
 Set x, y, z, and w components with pt.x, pt.y, z, and w. More...
 
template<typename U >
void set (const std::initializer_list< U > &lst)
 Set x, y, z, and w components with given initializer list. More...
 
void set (const Vector &v)
 Set x, y, z, and w with other vector v. More...
 
void setZero ()
 Set all x, y, z, and w to zero. More...
 
void normalize ()
 Normalizes this vector. More...
 
Vector add (T v) const
 Computes this + (v, v, v, v). More...
 
Vector add (const Vector &v) const
 Computes this + (v.x, v.y, v.z, v.w). More...
 
Vector sub (T v) const
 Computes this - (v, v, v, v). More...
 
Vector sub (const Vector &v) const
 Computes this - (v.x, v.y, v.z, v.w). More...
 
Vector mul (T v) const
 Computes this * (v, v, v, v). More...
 
Vector mul (const Vector &v) const
 Computes this * (v.x, v.y, v.z, v.w). More...
 
Vector div (T v) const
 Computes this / (v, v, v, v). More...
 
Vector div (const Vector &v) const
 Computes this / (v.x, v.y, v.z, v.w). More...
 
dot (const Vector &v) const
 Computes dot product. More...
 
Vector rsub (T v) const
 Computes (v, v, v, v) - this. More...
 
Vector rsub (const Vector &v) const
 Computes (v.x, v.y, v.z, v.w) - this. More...
 
Vector rdiv (T v) const
 Computes (v, v, v, v) / this. More...
 
Vector rdiv (const Vector &v) const
 Computes (v.x, v.y, v.z, v.w) / this. More...
 
void iadd (T v)
 Computes this += (v, v, v, v). More...
 
void iadd (const Vector &v)
 Computes this += (v.x, v.y, v.z, v.w). More...
 
void isub (T v)
 Computes this -= (v, v, v, v). More...
 
void isub (const Vector &v)
 Computes this -= (v.x, v.y, v.z, v.w). More...
 
void imul (T v)
 Computes this *= (v, v, v, v). More...
 
void imul (const Vector &v)
 Computes this *= (v.x, v.y, v.z, v.w). More...
 
void idiv (T v)
 Computes this /= (v, v, v, v). More...
 
void idiv (const Vector &v)
 Computes this /= (v.x, v.y, v.z, v.w). More...
 
const T & at (size_t i) const
 Returns const reference to the i -th element of the vector. More...
 
T & at (size_t i)
 Returns reference to the i -th element of the vector. More...
 
sum () const
 Returns the sum of all the components (i.e. x + y + z + w). More...
 
avg () const
 Returns the average of all the components. More...
 
min () const
 Returns the minimum value among x, y, z, and w. More...
 
max () const
 Returns the maximum value among x, y, z, and w. More...
 
absmin () const
 Returns the absolute minimum value among x, y, z, and w. More...
 
absmax () const
 Returns the absolute maximum value among x, y, z, and w. More...
 
size_t dominantAxis () const
 Returns the index of the dominant axis. More...
 
size_t subminantAxis () const
 Returns the index of the subminant axis. More...
 
Vector normalized () const
 Returns normalized vector. More...
 
length () const
 Returns the length of the vector. More...
 
lengthSquared () const
 Returns the squared length of the vector. More...
 
distanceTo (const Vector &other) const
 Returns the distance to the other vector. More...
 
distanceSquaredTo (const Vector &other) const
 Returns the squared distance to the other vector. More...
 
template<typename U >
Vector< U, 4 > castTo () const
 Returns a vector with different value type. More...
 
bool isEqual (const Vector &other) const
 Returns true if other is the same as this vector. More...
 
bool isSimilar (const Vector &other, T epsilon=std::numeric_limits< T >::epsilon()) const
 Returns true if other is similar to this vector. More...
 
T & operator[] (size_t i)
 Returns reference to the i -th element of the vector. More...
 
const T & operator[] (size_t i) const
 Returns const reference to the i -th element of the vector. More...
 
template<typename U >
Vectoroperator= (const std::initializer_list< U > &lst)
 Set x and y components with given initializer list. More...
 
Vectoroperator= (const Vector &v)
 Set x and y with other vector v. More...
 
Vectoroperator+= (T v)
 Computes this += (v, v, v, v) More...
 
Vectoroperator+= (const Vector &v)
 Computes this += (v.x, v.y, v.z, v.w) More...
 
Vectoroperator-= (T v)
 Computes this -= (v, v, v, v) More...
 
Vectoroperator-= (const Vector &v)
 Computes this -= (v.x, v.y, v.z, v.w) More...
 
Vectoroperator*= (T v)
 Computes this *= (v, v, v, v) More...
 
Vectoroperator*= (const Vector &v)
 Computes this *= (v.x, v.y, v.z, v.w) More...
 
Vectoroperator/= (T v)
 Computes this /= (v, v, v, v) More...
 
Vectoroperator/= (const Vector &v)
 Computes this /= (v.x, v.y, v.z, v.w) More...
 
bool operator== (const Vector &v) const
 Returns true if other is the same as this vector. More...
 
bool operator!= (const Vector &v) const
 Returns true if other is the not same as this vector. More...
 

Public Attributes

x
 X (or the first) component of the vector. More...
 
y
 Y (or the second) component of the vector. More...
 
z
 Z (or the third) component of the vector. More...
 
w
 W (or the fourth) component of the vector. More...
 

Detailed Description

template<typename T>
class jet::Vector< T, 4 >

4-D vector class.

This class defines simple 4-D vector data.

Template Parameters
T- Type of the element

Constructor & Destructor Documentation

◆ Vector() [1/5]

template<typename T >
constexpr jet::Vector< T, 4 >::Vector ( )
inlineconstexpr

Constructs default vector (0, 0, 0, 0).

◆ Vector() [2/5]

template<typename T >
constexpr jet::Vector< T, 4 >::Vector ( x_,
y_,
z_,
w_ 
)
inlineconstexpr

Constructs vector with given parameters x_, y_, z_, and w_.

◆ Vector() [3/5]

template<typename T >
constexpr jet::Vector< T, 4 >::Vector ( const Vector3< T > &  v,
w_ 
)
inlineconstexpr

Constructs vector with a 3-D vector (x, y, and z) and a scalar (w).

◆ Vector() [4/5]

template<typename T >
template<typename U >
jet::Vector< T, 4 >::Vector ( const std::initializer_list< U > &  lst)

Constructs vector with initializer list.

◆ Vector() [5/5]

template<typename T >
constexpr jet::Vector< T, 4 >::Vector ( const Vector< T, 4 > &  v)
inlineconstexpr

Copy constructor.

Member Function Documentation

◆ absmax()

template<typename T >
T jet::Vector< T, 4 >::absmax ( ) const

Returns the absolute maximum value among x, y, z, and w.

◆ absmin()

template<typename T >
T jet::Vector< T, 4 >::absmin ( ) const

Returns the absolute minimum value among x, y, z, and w.

◆ add() [1/2]

template<typename T >
Vector jet::Vector< T, 4 >::add ( const Vector< T, 4 > &  v) const

Computes this + (v.x, v.y, v.z, v.w).

◆ add() [2/2]

template<typename T >
Vector jet::Vector< T, 4 >::add ( v) const

Computes this + (v, v, v, v).

◆ at() [1/2]

template<typename T >
T& jet::Vector< T, 4 >::at ( size_t  i)

Returns reference to the i -th element of the vector.

◆ at() [2/2]

template<typename T >
const T& jet::Vector< T, 4 >::at ( size_t  i) const

Returns const reference to the i -th element of the vector.

◆ avg()

template<typename T >
T jet::Vector< T, 4 >::avg ( ) const

Returns the average of all the components.

◆ castTo()

template<typename T >
template<typename U >
Vector<U, 4> jet::Vector< T, 4 >::castTo ( ) const

Returns a vector with different value type.

◆ distanceSquaredTo()

template<typename T >
T jet::Vector< T, 4 >::distanceSquaredTo ( const Vector< T, 4 > &  other) const

Returns the squared distance to the other vector.

◆ distanceTo()

template<typename T >
T jet::Vector< T, 4 >::distanceTo ( const Vector< T, 4 > &  other) const

Returns the distance to the other vector.

◆ div() [1/2]

template<typename T >
Vector jet::Vector< T, 4 >::div ( const Vector< T, 4 > &  v) const

Computes this / (v.x, v.y, v.z, v.w).

◆ div() [2/2]

template<typename T >
Vector jet::Vector< T, 4 >::div ( v) const

Computes this / (v, v, v, v).

◆ dominantAxis()

template<typename T >
size_t jet::Vector< T, 4 >::dominantAxis ( ) const

Returns the index of the dominant axis.

◆ dot()

template<typename T >
T jet::Vector< T, 4 >::dot ( const Vector< T, 4 > &  v) const

Computes dot product.

◆ iadd() [1/2]

template<typename T >
void jet::Vector< T, 4 >::iadd ( const Vector< T, 4 > &  v)

Computes this += (v.x, v.y, v.z, v.w).

◆ iadd() [2/2]

template<typename T >
void jet::Vector< T, 4 >::iadd ( v)

Computes this += (v, v, v, v).

◆ idiv() [1/2]

template<typename T >
void jet::Vector< T, 4 >::idiv ( const Vector< T, 4 > &  v)

Computes this /= (v.x, v.y, v.z, v.w).

◆ idiv() [2/2]

template<typename T >
void jet::Vector< T, 4 >::idiv ( v)

Computes this /= (v, v, v, v).

◆ imul() [1/2]

template<typename T >
void jet::Vector< T, 4 >::imul ( const Vector< T, 4 > &  v)

Computes this *= (v.x, v.y, v.z, v.w).

◆ imul() [2/2]

template<typename T >
void jet::Vector< T, 4 >::imul ( v)

Computes this *= (v, v, v, v).

◆ isEqual()

template<typename T >
bool jet::Vector< T, 4 >::isEqual ( const Vector< T, 4 > &  other) const

Returns true if other is the same as this vector.

◆ isSimilar()

template<typename T >
bool jet::Vector< T, 4 >::isSimilar ( const Vector< T, 4 > &  other,
epsilon = std::numeric_limits< T >::epsilon() 
) const

Returns true if other is similar to this vector.

◆ isub() [1/2]

template<typename T >
void jet::Vector< T, 4 >::isub ( const Vector< T, 4 > &  v)

Computes this -= (v.x, v.y, v.z, v.w).

◆ isub() [2/2]

template<typename T >
void jet::Vector< T, 4 >::isub ( v)

Computes this -= (v, v, v, v).

◆ length()

template<typename T >
T jet::Vector< T, 4 >::length ( ) const

Returns the length of the vector.

◆ lengthSquared()

template<typename T >
T jet::Vector< T, 4 >::lengthSquared ( ) const

Returns the squared length of the vector.

◆ max()

template<typename T >
T jet::Vector< T, 4 >::max ( ) const

Returns the maximum value among x, y, z, and w.

◆ min()

template<typename T >
T jet::Vector< T, 4 >::min ( ) const

Returns the minimum value among x, y, z, and w.

◆ mul() [1/2]

template<typename T >
Vector jet::Vector< T, 4 >::mul ( const Vector< T, 4 > &  v) const

Computes this * (v.x, v.y, v.z, v.w).

◆ mul() [2/2]

template<typename T >
Vector jet::Vector< T, 4 >::mul ( v) const

Computes this * (v, v, v, v).

◆ normalize()

template<typename T >
void jet::Vector< T, 4 >::normalize ( )

Normalizes this vector.

◆ normalized()

template<typename T >
Vector jet::Vector< T, 4 >::normalized ( ) const

Returns normalized vector.

◆ operator!=()

template<typename T >
bool jet::Vector< T, 4 >::operator!= ( const Vector< T, 4 > &  v) const

Returns true if other is the not same as this vector.

◆ operator*=() [1/2]

template<typename T >
Vector& jet::Vector< T, 4 >::operator*= ( const Vector< T, 4 > &  v)

Computes this *= (v.x, v.y, v.z, v.w)

◆ operator*=() [2/2]

template<typename T >
Vector& jet::Vector< T, 4 >::operator*= ( v)

Computes this *= (v, v, v, v)

◆ operator+=() [1/2]

template<typename T >
Vector& jet::Vector< T, 4 >::operator+= ( const Vector< T, 4 > &  v)

Computes this += (v.x, v.y, v.z, v.w)

◆ operator+=() [2/2]

template<typename T >
Vector& jet::Vector< T, 4 >::operator+= ( v)

Computes this += (v, v, v, v)

◆ operator-=() [1/2]

template<typename T >
Vector& jet::Vector< T, 4 >::operator-= ( const Vector< T, 4 > &  v)

Computes this -= (v.x, v.y, v.z, v.w)

◆ operator-=() [2/2]

template<typename T >
Vector& jet::Vector< T, 4 >::operator-= ( v)

Computes this -= (v, v, v, v)

◆ operator/=() [1/2]

template<typename T >
Vector& jet::Vector< T, 4 >::operator/= ( const Vector< T, 4 > &  v)

Computes this /= (v.x, v.y, v.z, v.w)

◆ operator/=() [2/2]

template<typename T >
Vector& jet::Vector< T, 4 >::operator/= ( v)

Computes this /= (v, v, v, v)

◆ operator=() [1/2]

template<typename T >
template<typename U >
Vector& jet::Vector< T, 4 >::operator= ( const std::initializer_list< U > &  lst)

Set x and y components with given initializer list.

◆ operator=() [2/2]

template<typename T >
Vector& jet::Vector< T, 4 >::operator= ( const Vector< T, 4 > &  v)

Set x and y with other vector v.

◆ operator==()

template<typename T >
bool jet::Vector< T, 4 >::operator== ( const Vector< T, 4 > &  v) const

Returns true if other is the same as this vector.

◆ operator[]() [1/2]

template<typename T >
T& jet::Vector< T, 4 >::operator[] ( size_t  i)

Returns reference to the i -th element of the vector.

◆ operator[]() [2/2]

template<typename T >
const T& jet::Vector< T, 4 >::operator[] ( size_t  i) const

Returns const reference to the i -th element of the vector.

◆ rdiv() [1/2]

template<typename T >
Vector jet::Vector< T, 4 >::rdiv ( const Vector< T, 4 > &  v) const

Computes (v.x, v.y, v.z, v.w) / this.

◆ rdiv() [2/2]

template<typename T >
Vector jet::Vector< T, 4 >::rdiv ( v) const

Computes (v, v, v, v) / this.

◆ rsub() [1/2]

template<typename T >
Vector jet::Vector< T, 4 >::rsub ( const Vector< T, 4 > &  v) const

Computes (v.x, v.y, v.z, v.w) - this.

◆ rsub() [2/2]

template<typename T >
Vector jet::Vector< T, 4 >::rsub ( v) const

Computes (v, v, v, v) - this.

◆ set() [1/5]

template<typename T >
template<typename U >
void jet::Vector< T, 4 >::set ( const std::initializer_list< U > &  lst)

Set x, y, z, and w components with given initializer list.

◆ set() [2/5]

template<typename T >
void jet::Vector< T, 4 >::set ( const Vector< T, 4 > &  v)

Set x, y, z, and w with other vector v.

◆ set() [3/5]

template<typename T >
void jet::Vector< T, 4 >::set ( const Vector< T, 3 > &  pt,
z 
)

Set x, y, z, and w components with pt.x, pt.y, z, and w.

◆ set() [4/5]

template<typename T >
void jet::Vector< T, 4 >::set ( s)

Set both x, y, z, and w components to s.

◆ set() [5/5]

template<typename T >
void jet::Vector< T, 4 >::set ( x,
y,
z,
w 
)

Set x, y, z, and w components with given parameters.

◆ setZero()

template<typename T >
void jet::Vector< T, 4 >::setZero ( )

Set all x, y, z, and w to zero.

◆ sub() [1/2]

template<typename T >
Vector jet::Vector< T, 4 >::sub ( const Vector< T, 4 > &  v) const

Computes this - (v.x, v.y, v.z, v.w).

◆ sub() [2/2]

template<typename T >
Vector jet::Vector< T, 4 >::sub ( v) const

Computes this - (v, v, v, v).

◆ subminantAxis()

template<typename T >
size_t jet::Vector< T, 4 >::subminantAxis ( ) const

Returns the index of the subminant axis.

◆ sum()

template<typename T >
T jet::Vector< T, 4 >::sum ( ) const

Returns the sum of all the components (i.e. x + y + z + w).

Member Data Documentation

◆ w

template<typename T >
T jet::Vector< T, 4 >::w

W (or the fourth) component of the vector.

◆ x

template<typename T >
T jet::Vector< T, 4 >::x

X (or the first) component of the vector.

◆ y

template<typename T >
T jet::Vector< T, 4 >::y

Y (or the second) component of the vector.

◆ z

template<typename T >
T jet::Vector< T, 4 >::z

Z (or the third) component of the vector.


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