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

3-D vector class. More...

#include <jet/vector3.h>

Public Member Functions

constexpr Vector ()
 Constructs default vector (0, 0, 0). More...
 
constexpr Vector (T x_, T y_, T z_)
 Constructs vector with given parameters x_, y_, and z_. More...
 
constexpr Vector (const Vector2< T > &v, T z_)
 Constructs vector with a 2-D vector and a scalar. 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 all x, y, and z components to s. More...
 
void set (T x, T y, T z)
 Set x, y, and z components with given parameters. More...
 
void set (const Vector2< T > &pt, T z)
 Set x, y, and z components with given pt.x, pt.y, and z. More...
 
template<typename U >
void set (const std::initializer_list< U > &lst)
 Set x, y, and z components with given initializer list. More...
 
void set (const Vector &v)
 Set x, y, and z with other vector v. More...
 
void setZero ()
 Set all x, y, and z to zero. More...
 
void normalize ()
 Normalizes this vector. More...
 
Vector add (T v) const
 Computes this + (v, v, v). More...
 
Vector add (const Vector &v) const
 Computes this + (v.x, v.y, v.z). More...
 
Vector sub (T v) const
 Computes this - (v, v, v). More...
 
Vector sub (const Vector &v) const
 Computes this - (v.x, v.y, v.z). More...
 
Vector mul (T v) const
 Computes this * (v, v, v). More...
 
Vector mul (const Vector &v) const
 Computes this * (v.x, v.y, v.z). More...
 
Vector div (T v) const
 Computes this / (v, v, v). More...
 
Vector div (const Vector &v) const
 Computes this / (v.x, v.y, v.z). More...
 
T dot (const Vector &v) const
 Computes dot product. More...
 
Vector cross (const Vector &v) const
 Comptues cross product. More...
 
Vector rsub (T v) const
 Computes (v, v, v) - this. More...
 
Vector rsub (const Vector &v) const
 Computes (v.x, v.y, v.z) - this. More...
 
Vector rdiv (T v) const
 Computes (v, v, v) / this. More...
 
Vector rdiv (const Vector &v) const
 Computes (v.x, v.y, v.z) / this. More...
 
Vector rcross (const Vector &v) const
 Computes v cross this. More...
 
void iadd (T v)
 Computes this += (v, v, v). More...
 
void iadd (const Vector &v)
 Computes this += (v.x, v.y, v.z). More...
 
void isub (T v)
 Computes this -= (v, v, v). More...
 
void isub (const Vector &v)
 Computes this -= (v.x, v.y, v.z). More...
 
void imul (T v)
 Computes this *= (v, v, v). More...
 
void imul (const Vector &v)
 Computes this *= (v.x, v.y, v.z). More...
 
void idiv (T v)
 Computes this /= (v, v, v). More...
 
void idiv (const Vector &v)
 Computes this /= (v.x, v.y, v.z). 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...
 
T sum () const
 Returns the sum of all the components (i.e. x + y + z). More...
 
T avg () const
 Returns the average of all the components. More...
 
T min () const
 Returns the minimum value among x, y, and z. More...
 
T max () const
 Returns the maximum value among x, y, and z. More...
 
T absmin () const
 Returns the absolute minimum value among x, y, and z. More...
 
T absmax () const
 Returns the absolute maximum value among x, y, and z. 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...
 
T length () const
 Returns the length of the vector. More...
 
T lengthSquared () const
 Returns the squared length of the vector. More...
 
T distanceTo (const Vector &other) const
 Returns the distance to the other vector. More...
 
T distanceSquaredTo (const Vector &other) const
 Returns the squared distance to the other vector. More...
 
Vector reflected (const Vector &normal) const
 Returns the reflection vector to the surface with given surface normal. More...
 
Vector projected (const Vector &normal) const
 Returns the projected vector to the surface with given surface normal. More...
 
std::tuple< Vector, Vector > tangential () const
 Returns the tangential vector for this vector. More...
 
template<typename U >
Vector< U, 3 > 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 >
Vector & operator= (const std::initializer_list< U > &lst)
 Set x and y components with given initializer list. More...
 
Vector & operator= (const Vector &v)
 Set x and y with other vector pt. More...
 
Vector & operator+= (T v)
 Computes this += (v, v, v) More...
 
Vector & operator+= (const Vector &v)
 Computes this += (v.x, v.y, v.z) More...
 
Vector & operator-= (T v)
 Computes this -= (v, v, v) More...
 
Vector & operator-= (const Vector &v)
 Computes this -= (v.x, v.y, v.z) More...
 
Vector & operator*= (T v)
 Computes this *= (v, v, v) More...
 
Vector & operator*= (const Vector &v)
 Computes this *= (v.x, v.y, v.z) More...
 
Vector & operator/= (T v)
 Computes this /= (v, v, v) More...
 
Vector & operator/= (const Vector &v)
 Computes this /= (v.x, v.y, v.z) 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

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

Detailed Description

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

3-D vector class.

This class defines simple 3-D vector data.

Template Parameters
T- Type of the element

Constructor & Destructor Documentation

◆ Vector() [1/5]

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

Constructs default vector (0, 0, 0).

◆ Vector() [2/5]

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

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

◆ Vector() [3/5]

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

Constructs vector with a 2-D vector and a scalar.

◆ Vector() [4/5]

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

Constructs vector with initializer list.

◆ Vector() [5/5]

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

Copy constructor.

Member Function Documentation

◆ absmax()

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

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

◆ absmin()

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

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

◆ add() [1/2]

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

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

◆ add() [2/2]

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

Computes this + (v, v, v).

◆ at() [1/2]

template<typename T >
T& jet::Vector< T, 3 >::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, 3 >::at ( size_t  i) const

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

◆ avg()

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

Returns the average of all the components.

◆ castTo()

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

Returns a vector with different value type.

◆ cross()

template<typename T >
Vector jet::Vector< T, 3 >::cross ( const Vector< T, 3 > &  v) const

Comptues cross product.

◆ distanceSquaredTo()

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

Returns the squared distance to the other vector.

◆ distanceTo()

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

Returns the distance to the other vector.

◆ div() [1/2]

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

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

◆ div() [2/2]

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

Computes this / (v, v, v).

◆ dominantAxis()

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

Returns the index of the dominant axis.

◆ dot()

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

Computes dot product.

◆ iadd() [1/2]

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

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

◆ iadd() [2/2]

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

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

◆ idiv() [1/2]

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

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

◆ idiv() [2/2]

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

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

◆ imul() [1/2]

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

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

◆ imul() [2/2]

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

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

◆ isEqual()

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

Returns true if other is the same as this vector.

◆ isSimilar()

template<typename T >
bool jet::Vector< T, 3 >::isSimilar ( const Vector< T, 3 > &  other,
T  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, 3 >::isub ( const Vector< T, 3 > &  v)

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

◆ isub() [2/2]

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

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

◆ length()

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

Returns the length of the vector.

◆ lengthSquared()

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

Returns the squared length of the vector.

◆ max()

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

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

◆ min()

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

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

◆ mul() [1/2]

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

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

◆ mul() [2/2]

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

Computes this * (v, v, v).

◆ normalize()

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

Normalizes this vector.

◆ normalized()

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

Returns normalized vector.

◆ operator!=()

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

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

◆ operator*=() [1/2]

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

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

◆ operator*=() [2/2]

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

Computes this *= (v, v, v)

◆ operator+=() [1/2]

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

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

◆ operator+=() [2/2]

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

Computes this += (v, v, v)

◆ operator-=() [1/2]

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

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

◆ operator-=() [2/2]

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

Computes this -= (v, v, v)

◆ operator/=() [1/2]

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

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

◆ operator/=() [2/2]

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

Computes this /= (v, v, v)

◆ operator=() [1/2]

template<typename T >
template<typename U >
Vector& jet::Vector< T, 3 >::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, 3 >::operator= ( const Vector< T, 3 > &  v)

Set x and y with other vector pt.

◆ operator==()

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

Returns true if other is the same as this vector.

◆ operator[]() [1/2]

template<typename T >
T& jet::Vector< T, 3 >::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, 3 >::operator[] ( size_t  i) const

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

◆ projected()

template<typename T >
Vector jet::Vector< T, 3 >::projected ( const Vector< T, 3 > &  normal) const

Returns the projected vector to the surface with given surface normal.

◆ rcross()

template<typename T >
Vector jet::Vector< T, 3 >::rcross ( const Vector< T, 3 > &  v) const

Computes v cross this.

◆ rdiv() [1/2]

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

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

◆ rdiv() [2/2]

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

Computes (v, v, v) / this.

◆ reflected()

template<typename T >
Vector jet::Vector< T, 3 >::reflected ( const Vector< T, 3 > &  normal) const

Returns the reflection vector to the surface with given surface normal.

◆ rsub() [1/2]

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

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

◆ rsub() [2/2]

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

Computes (v, v, v) - this.

◆ set() [1/5]

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

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

◆ set() [2/5]

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

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

◆ set() [3/5]

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

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

◆ set() [4/5]

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

Set all x, y, and z components to s.

◆ set() [5/5]

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

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

◆ setZero()

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

Set all x, y, and z to zero.

◆ sub() [1/2]

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

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

◆ sub() [2/2]

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

Computes this - (v, v, v).

◆ subminantAxis()

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

Returns the index of the subminant axis.

◆ sum()

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

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

◆ tangential()

template<typename T >
std::tuple<Vector, Vector> jet::Vector< T, 3 >::tangential ( ) const

Returns the tangential vector for this vector.

Member Data Documentation

◆ x

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

X (or the first) component of the vector.

◆ y

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

Y (or the second) component of the vector.

◆ z

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

Z (or the third) component of the vector.


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