Hermes
hermes::Vector3< T > Class Template Reference

Geometric 3-dimensional vector (x, y, z) More...

+ Inheritance diagram for hermes::Vector3< T >:

Public Member Functions

HERMES_DEVICE_CALLABLE Vector3 ()
 Default constructor.
 
HERMES_DEVICE_CALLABLE Vector3 (T _f)
 Constructs from single component value. More...
 
HERMES_DEVICE_CALLABLE Vector3 (T _x, T _y, T _z)
 Constructs from component values. More...
 
HERMES_DEVICE_CALLABLE Vector3 (const T *v)
 Constructs from component array. More...
 
HERMES_DEVICE_CALLABLE Vector3 (const Point3< T > &p)
 Casts from geometric point. More...
 
template<typename S , typename C = T>
HERMES_DEVICE_CALLABLE Vector3 (const Vector3< Interval< S >> &vi, typename std::enable_if_t< !std::is_same_v< C, Interval< f32 >> &&!std::is_same_v< C, Interval< f64 >>> *=nullptr)
 Constructs from interval. More...
 
HERMES_DEVICE_CALLABLE Vector3operator= (const T &v)
 Copy assign. More...
 
HERMES_DEVICE_CALLABLE Vector3< T > & operator/= (T f)
 
HERMES_DEVICE_CALLABLE Vector3< T > & operator/= (const Vector3< T > &v)
 
HERMES_DEVICE_CALLABLE Vector3< T > operator/ (const T &f) const
 
HERMES_DEVICE_CALLABLE Vector3< T > operator- () const
 
HERMES_DEVICE_CALLABLE bool operator== (const Vector3< T > &b) const
 
HERMES_DEVICE_CALLABLE bool operator< (const Vector3< T > &b) const
 
HERMES_DEVICE_CALLABLE bool operator> (const Vector3< T > &b) const
 
HERMES_DEVICE_CALLABLE bool operator>= (const Vector3< T > &b) const
 
HERMES_DEVICE_CALLABLE bool operator<= (const Vector3< T > &b) const
 
HERMES_DEVICE_CALLABLEoperator[] (int i) const
 Get i-th component. More...
 
HERMES_DEVICE_CALLABLE T & operator[] (int i)
 Get i-th component reference. More...
 
HERMES_DEVICE_CALLABLE Vector2< T > xy (int i=0, int j=1) const
 Gets 2-dimensional swizzle form. More...
 
HERMES_DEVICE_CALLABLEmLength () const
 Computes Manhattan distance. More...
 
template<typename C = T>
HERMES_DEVICE_CALLABLElength (typename std::enable_if_t<!std::is_same_v< C, Interval< f32 >> &&!std::is_same_v< C, Interval< f64 >>> *=nullptr) const
 Computes vector magnitude. More...
 
template<typename C = T>
HERMES_DEVICE_CALLABLElength (typename std::enable_if_t< std::is_same_v< C, Interval< f32 >>||std::is_same_v< C, Interval< f64 >>> *=nullptr) const
 Computes vector magnitude. More...
 
HERMES_DEVICE_CALLABLElength2 () const
 Computes vector squared magnitude. More...
 
HERMES_DEVICE_CALLABLEmaxAbs () const
 Gets maximum absolute component value. More...
 
HERMES_DEVICE_CALLABLEmax () const
 Gets maximum component value. More...
 
HERMES_DEVICE_CALLABLE int maxDimension () const
 Gets index of component with maximum value. More...
 
HERMES_DEVICE_CALLABLE int maxAbsDimension () const
 Gets index of component with maximum absolute value. More...
 
HERMES_DEVICE_CALLABLE void normalize ()
 Normalizes this vector. More...
 
HERMES_DEVICE_CALLABLE Vector3 normalized () const
 Gets a normalized copy of this vector. More...
 
HERMES_DEVICE_CALLABLE Vector3 projectOnto (const Vector3 &b)
 Projects this vector onto b. More...
 
HERMES_DEVICE_CALLABLE Vector3 rejectOn (const Vector3 b)
 Rejects this vector on b. More...
 
HERMES_DEVICE_CALLABLE bool hasNaNs () const
 Check for nans. More...
 

Public Attributes

x = T(0.0)
 0-th component
 
y = T(0.0)
 1-th component
 
z = T(0.0)
 2-th component
 

Additional Inherited Members

- Static Public Member Functions inherited from hermes::MathElement< T, 3u >
static constexpr u64 componentCount ()
 Gets the number of dimensional components. More...
 
static constexpr u64 numericTypeSizeInBytes ()
 Gets the size in bytes of underlying data type. More...
 
static MemoryDumper::RegionLayout memoryDumpLayout ()
 Gets memory layout. More...
 
- Static Public Attributes inherited from hermes::MathElement< T, 3u >
static T numeric_data
 Underlying data type.
 

Detailed Description

template<typename T>
class hermes::Vector3< T >

Geometric 3-dimensional vector (x, y, z)

Template Parameters
T

Constructor & Destructor Documentation

◆ Vector3() [1/5]

template<typename T >
HERMES_DEVICE_CALLABLE hermes::Vector3< T >::Vector3 ( _f)
inlineexplicit

Constructs from single component value.

Parameters
_f

◆ Vector3() [2/5]

template<typename T >
HERMES_DEVICE_CALLABLE hermes::Vector3< T >::Vector3 ( _x,
_y,
_z 
)
inline

Constructs from component values.

Parameters
_x
_y
_z

◆ Vector3() [3/5]

template<typename T >
HERMES_DEVICE_CALLABLE hermes::Vector3< T >::Vector3 ( const T *  v)
inlineexplicit

Constructs from component array.

Parameters
v

◆ Vector3() [4/5]

template<typename T >
HERMES_DEVICE_CALLABLE hermes::Vector3< T >::Vector3 ( const Point3< T > &  p)
inlineexplicit

Casts from geometric point.

Parameters
p

◆ Vector3() [5/5]

template<typename T >
template<typename S , typename C = T>
HERMES_DEVICE_CALLABLE hermes::Vector3< T >::Vector3 ( const Vector3< Interval< S >> &  vi,
typename std::enable_if_t< !std::is_same_v< C, Interval< f32 >> &&!std::is_same_v< C, Interval< f64 >>> *  = nullptr 
)
inlineexplicit

Constructs from interval.

Template Parameters
S
C
Parameters
vi

Member Function Documentation

◆ hasNaNs()

template<typename T >
HERMES_DEVICE_CALLABLE bool hermes::Vector3< T >::hasNaNs ( ) const
inline

Check for nans.

Returns

◆ length() [1/2]

template<typename T >
template<typename C = T>
HERMES_DEVICE_CALLABLE T hermes::Vector3< T >::length ( typename std::enable_if_t< std::is_same_v< C, Interval< f32 >>||std::is_same_v< C, Interval< f64 >>> *  = nullptr) const
inline

Computes vector magnitude.

Template Parameters
C
Returns

◆ length() [2/2]

template<typename T >
template<typename C = T>
HERMES_DEVICE_CALLABLE T hermes::Vector3< T >::length ( typename std::enable_if_t<!std::is_same_v< C, Interval< f32 >> &&!std::is_same_v< C, Interval< f64 >>> *  = nullptr) const
inline

Computes vector magnitude.

Note
Also called L2-norm, Euclidean norm, Euclidean distance, 2-norm
Defined as ||v|| = (v_i * v_i)^(1/2)
Returns
2-norm of this vector

◆ length2()

template<typename T >
HERMES_DEVICE_CALLABLE T hermes::Vector3< T >::length2 ( ) const
inline

Computes vector squared magnitude.

Note
Also called squared Euclidean distance
Defined as ||v||^2 = v_i * v_i
Returns
squared 2-norm of this vector

◆ max()

template<typename T >
HERMES_DEVICE_CALLABLE T hermes::Vector3< T >::max ( ) const
inline

Gets maximum component value.

Note
Defined as argmax v_i
Returns
greatest component value

◆ maxAbs()

template<typename T >
HERMES_DEVICE_CALLABLE T hermes::Vector3< T >::maxAbs ( ) const
inline

Gets maximum absolute component value.

Note
Also called maximum norm, infinity norm
Defined as ||v||_inf = argmax max(|v_i|)
Returns
greatest absolute component value

◆ maxAbsDimension()

template<typename T >
HERMES_DEVICE_CALLABLE int hermes::Vector3< T >::maxAbsDimension ( ) const
inline

Gets index of component with maximum absolute value.

Note
Defined as argmax_i |v_i|
Returns
Index of dimension with greatest value

◆ maxDimension()

template<typename T >
HERMES_DEVICE_CALLABLE int hermes::Vector3< T >::maxDimension ( ) const
inline

Gets index of component with maximum value.

Note
Defined as argmax_i v_i
Returns
Index of component with greatest value

◆ mLength()

template<typename T >
HERMES_DEVICE_CALLABLE T hermes::Vector3< T >::mLength ( ) const
inline

Computes Manhattan distance.

Note
Also called L1-norm, taxicab norm, Manhattan norm
Defined as ||v||_1 = sum_i(|v_i|)
Returns
L1-norm of this vector

◆ normalize()

template<typename T >
HERMES_DEVICE_CALLABLE void hermes::Vector3< T >::normalize ( )
inline

Normalizes this vector.

Note
Normalization by vector length
Defined as v / ||v||

◆ normalized()

template<typename T >
HERMES_DEVICE_CALLABLE Vector3 hermes::Vector3< T >::normalized ( ) const
inline

Gets a normalized copy of this vector.

Note
Normalization by vector length
Defined as v / ||v||
Returns
Normalized vector of this vector

◆ operator=()

template<typename T >
HERMES_DEVICE_CALLABLE Vector3& hermes::Vector3< T >::operator= ( const T &  v)
inline

Copy assign.

Parameters
v
Returns

◆ operator[]() [1/2]

template<typename T >
HERMES_DEVICE_CALLABLE T& hermes::Vector3< T >::operator[] ( int  i)
inline

Get i-th component reference.

Warning
i is not checked
Parameters
icomponent index in [0, 2]
Returns

◆ operator[]() [2/2]

template<typename T >
HERMES_DEVICE_CALLABLE T hermes::Vector3< T >::operator[] ( int  i) const
inline

Get i-th component.

Warning
i is not checked
Parameters
icomponent index in [0, 2]
Returns

◆ projectOnto()

template<typename T >
HERMES_DEVICE_CALLABLE Vector3 hermes::Vector3< T >::projectOnto ( const Vector3< T > &  b)
inline

Projects this vector onto b.

Note
b * dot(v,b) / ||b||
Parameters
bvector to project onto
Returns
projection of this vector onto b

◆ rejectOn()

template<typename T >
HERMES_DEVICE_CALLABLE Vector3 hermes::Vector3< T >::rejectOn ( const Vector3< T >  b)
inline

Rejects this vector on b.

Note
v - b * dot(v,b) / ||b||
Parameters
bvector of rejection
Returns
rejection of this vector on b

◆ xy()

template<typename T >
HERMES_DEVICE_CALLABLE Vector2<T> hermes::Vector3< T >::xy ( int  i = 0,
int  j = 1 
) const
inline

Gets 2-dimensional swizzle form.

Parameters
i
j
Returns

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