AGX Dynamics  2.35.0.1
agx::Vec4T< T > Class Template Reference

A class holding 4 dimensional vectors and providing basic arithmetic. More...

#include <Vec4Template.h>

+ Inheritance diagram for agx::Vec4T< T >:

Public Types

typedef T Type
 

Public Member Functions

 Vec4T ()
 Default constructor. More...
 
 Vec4T (const T v[4])
 Constructor, initialize elements with the specified scalars. More...
 
 Vec4T (const Vec3T< T > &v3, T w)
 Constructor, initialize the first three elements with v3 and the last with w. More...
 
 Vec4T (const Vec4T &copy)=default
 Copy constructor. More...
 
template<typename T2 >
 Vec4T (const Vec4T< T2 > &copy)
 Copy constructor for other types. More...
 
 Vec4T (T r)
 Constructor, fill all elements with scalar r. More...
 
 Vec4T (T x, T y, T z, T w)
 Constructor, initialize elements with the specified scalars. More...
 
Vec3T< T > asVec3 () const
 
T at (size_t i)
 
void clamp (const Vec4T &min, const Vec4T &max)
 Clamp a vector between a lower and upper bound (per component). More...
 
Real distance (const Vec4T &v2) const
 
Real distance2 (const Vec4T &v2) const
 
Real distance2 (const Vec4T &v2) const
 
Real distance2 (const Vec4T &v2) const
 
Real distance2 (const Vec4T &v2) const
 
Real distance2 (const Vec4T &v2) const
 
bool equalsZero () const
 
bool isFinite () const
 
bool isNaN () const
 
bool isValid () const
 
Real length () const
 
Real length2 () const
 
T maxComponent () const
 
size_t maxElement () const
 
T minComponent () const
 
size_t minElement () const
 
Real normalize ()
 Normalize the vector so that it has length unity. More...
 
bool operator!= (const Vec4T &v) const
 In-equality test. More...
 
T operator* (const Vec4T &rhs) const
 
const Vec4T operator* (T rhs) const
 
Vec4T & operator*= (T rhs)
 
const Vec4T operator+ (const T &rhs) const
 Binary vector add. More...
 
const Vec4T operator+ (const Vec4T &rhs) const
 Binary vector add. More...
 
Vec4T & operator+= (const T &rhs)
 Unary vector add. More...
 
Vec4T & operator+= (const Vec4T &rhs)
 Unary vector add. More...
 
const Vec4T operator- () const
 Negation operator. More...
 
const Vec4T operator- (const T &rhs) const
 Binary vector subtract. More...
 
const Vec4T operator- (const Vec4T &rhs) const
 Binary vector subtract. More...
 
Vec4T & operator-= (const T &rhs)
 Unary vector subtract. More...
 
Vec4T & operator-= (const Vec4T &rhs)
 Unary vector subtract. More...
 
const Vec4T operator/ (T rhs) const
 Divide by scalar. More...
 
Vec4T & operator/= (T rhs)
 
bool operator== (const Vec4T &v) const
 Equality test. More...
 
T & operator[] (size_t i)
 
const T & operator[] (size_t i) const
 
const Vec4T operator| (const Vec4T &rhs) const
 
T * ptr ()
 
const T * ptr () const
 
void set (const Vec4T &rhs)
 Set the value of the vector with rhs. More...
 
void set (T val, size_t i)
 Set the value of element i. Mainly for accessing vec4 in Lua. More...
 
void set (T value)
 Set all elements of the vector with scalar value value. More...
 
void set (T x, T y, T z, T w)
 Set the elements of the vector. More...
 
T & w ()
 
T w () const
 
T & x ()
 
T x () const
 
T & y ()
 
T y () const
 
T & z ()
 
T z () const
 

Static Public Member Functions

static Vec4T componentMax (const Vec4T &v1, const Vec4T &v2)
 
static Vec4T componentMin (const Vec4T &v1, const Vec4T &v2)
 
static Vec4T random (const Vec4T &min, const Vec4T &max)
 
static Vec4T random (T min, T max)
 

Detailed Description

template<typename T>
class agx::Vec4T< T >

A class holding 4 dimensional vectors and providing basic arithmetic.

Definition at line 34 of file Vec4Template.h.

Member Typedef Documentation

◆ Type

template<typename T >
typedef T agx::Vec4T< T >::Type

Definition at line 37 of file Vec4Template.h.

Constructor & Destructor Documentation

◆ Vec4T() [1/7]

template<typename T >
agx::Vec4T< T >::Vec4T ( const Vec4T< T > &  copy)
default

Copy constructor.

◆ Vec4T() [2/7]

template<typename T >
template<typename T2 >
agx::Vec4T< T >::Vec4T ( const Vec4T< T2 > &  copy)
explicit

Copy constructor for other types.

Definition at line 304 of file Vec4Template.h.

◆ Vec4T() [3/7]

template<typename T >
agx::Vec4T< T >::Vec4T

Default constructor.

Definition at line 315 of file Vec4Template.h.

◆ Vec4T() [4/7]

template<typename T >
agx::Vec4T< T >::Vec4T ( T  r)
explicit

Constructor, fill all elements with scalar r.

Definition at line 324 of file Vec4Template.h.

◆ Vec4T() [5/7]

template<typename T >
agx::Vec4T< T >::Vec4T ( T  x,
T  y,
T  z,
T  w 
)

Constructor, initialize elements with the specified scalars.

Definition at line 330 of file Vec4Template.h.

◆ Vec4T() [6/7]

template<typename T >
agx::Vec4T< T >::Vec4T ( const T  v[4])
explicit

Constructor, initialize elements with the specified scalars.

Definition at line 339 of file Vec4Template.h.

◆ Vec4T() [7/7]

template<typename T >
agx::Vec4T< T >::Vec4T ( const Vec3T< T > &  v3,
T  w 
)

Constructor, initialize the first three elements with v3 and the last with w.

Definition at line 348 of file Vec4Template.h.

Member Function Documentation

◆ asVec3()

template<typename T >
Vec3T< T > agx::Vec4T< T >::asVec3
Returns
the x, y and z components as a Vec3

Definition at line 720 of file Vec4Template.h.

◆ at()

template<typename T >
T agx::Vec4T< T >::at ( size_t  i)
Returns
the element at i. Mainly for accessing vec4 in Lua.

Definition at line 708 of file Vec4Template.h.

◆ clamp()

template<typename T >
void agx::Vec4T< T >::clamp ( const Vec4T< T > &  min,
const Vec4T< T > &  max 
)

Clamp a vector between a lower and upper bound (per component).

Definition at line 425 of file Vec4Template.h.

References agx::clamp(), agx::max(), and agx::min().

Referenced by agx::clamp().

◆ componentMax()

template<typename T >
Vec4T< T > agx::Vec4T< T >::componentMax ( const Vec4T< T > &  v1,
const Vec4T< T > &  v2 
)
static
Returns
a new vector where each component is the maximum of this and the other vector.

Definition at line 377 of file Vec4Template.h.

References agx::max().

◆ componentMin()

template<typename T >
Vec4T< T > agx::Vec4T< T >::componentMin ( const Vec4T< T > &  v1,
const Vec4T< T > &  v2 
)
static
Returns
a new vector where each component is the minimum of this and the other vector.

Definition at line 371 of file Vec4Template.h.

References agx::min().

◆ distance()

template<typename T >
Real agx::Vec4T< T >::distance ( const Vec4T< T > &  v2) const
Returns
Distance to another vector

Definition at line 687 of file Vec4Template.h.

◆ distance2() [1/5]

template<typename T >
Real agx::Vec4T< T >::distance2 ( const Vec4T< T > &  v2) const
Returns
squared distance to another vector

Definition at line 780 of file Vec4Template.h.

References agx::Vec4T< T >::length2().

◆ distance2() [2/5]

Real agx::Vec4T< UInt8 >::distance2 ( const Vec4T< T > &  v2) const

Definition at line 788 of file Vec4Template.h.

References agx::Vec4T< T >::length2(), agx::max(), and agx::min().

◆ distance2() [3/5]

Real agx::Vec4T< UInt16 >::distance2 ( const Vec4T< T > &  v2) const

Definition at line 800 of file Vec4Template.h.

References agx::Vec4T< T >::length2(), agx::max(), and agx::min().

◆ distance2() [4/5]

Real agx::Vec4T< UInt32 >::distance2 ( const Vec4T< T > &  v2) const

Definition at line 812 of file Vec4Template.h.

References agx::Vec4T< T >::length2(), agx::max(), and agx::min().

◆ distance2() [5/5]

Real agx::Vec4T< UInt64 >::distance2 ( const Vec4T< T > &  v2) const

Definition at line 824 of file Vec4Template.h.

References agx::Vec4T< T >::length2(), agx::max(), and agx::min().

◆ equalsZero()

template<typename T >
bool agx::Vec4T< T >::equalsZero
Returns
true if all elements are zero

Definition at line 435 of file Vec4Template.h.

References agx::equalsZero().

◆ isFinite()

template<typename T >
bool agx::Vec4T< T >::isFinite
Returns
true if all of the elements is are non-NaN and non-inf

Definition at line 549 of file Vec4Template.h.

References agx::isFinite().

◆ isNaN()

template<typename T >
bool agx::Vec4T< T >::isNaN
Returns
true if any of the elements is NAN

Definition at line 543 of file Vec4Template.h.

References agx::isNaN().

◆ isValid()

template<typename T >
bool agx::Vec4T< T >::isValid
Returns
true if all elements is valid

Definition at line 537 of file Vec4Template.h.

References agx::isNaN().

◆ length()

template<typename T >
Real agx::Vec4T< T >::length
Returns
length of the vector = sqrt( vec . vec )

Definition at line 674 of file Vec4Template.h.

Referenced by agx::Vec4T< T >::normalize().

◆ length2()

template<typename T >
Real agx::Vec4T< T >::length2
Returns
spared length of the vector = vec . vec

Definition at line 680 of file Vec4Template.h.

Referenced by agx::Vec4T< T >::distance2().

◆ maxComponent()

template<typename T >
T agx::Vec4T< T >::maxComponent
Returns
the largest component (in absolute value).

Definition at line 389 of file Vec4Template.h.

References agx::max().

◆ maxElement()

template<typename T >
size_t agx::Vec4T< T >::maxElement
Returns
the index of the largest element (in absolute value)

Definition at line 410 of file Vec4Template.h.

References agx::absolute().

◆ minComponent()

template<typename T >
T agx::Vec4T< T >::minComponent
Returns
the smallest component (in absolute value).

Definition at line 383 of file Vec4Template.h.

References agx::min().

◆ minElement()

template<typename T >
size_t agx::Vec4T< T >::minElement
Returns
the index of the smallest element (in absolute value)

Definition at line 395 of file Vec4Template.h.

References agx::absolute().

◆ normalize()

template<typename T >
Real agx::Vec4T< T >::normalize

Normalize the vector so that it has length unity.

Returns
the previous length of the vector.

Definition at line 694 of file Vec4Template.h.

References agx::Vec4T< T >::length().

◆ operator!=()

template<typename T >
bool agx::Vec4T< T >::operator!= ( const Vec4T< T > &  v) const

In-equality test.

Definition at line 364 of file Vec4Template.h.

◆ operator*() [1/2]

template<typename T >
T agx::Vec4T< T >::operator* ( const Vec4T< T > &  rhs) const
Returns
the Dot product.

Definition at line 555 of file Vec4Template.h.

◆ operator*() [2/2]

template<typename T >
const Vec4T< T > agx::Vec4T< T >::operator* ( T  rhs) const
Returns
a new Vec4 multiplied by scalar rhs.

Definition at line 570 of file Vec4Template.h.

◆ operator*=()

template<typename T >
Vec4T< T > & agx::Vec4T< T >::operator*= ( T  rhs)
Returns
a reference to the Vec4 Unary multiplied by the scalar rhs

Definition at line 577 of file Vec4Template.h.

◆ operator+() [1/2]

template<typename T >
const Vec4T< T > agx::Vec4T< T >::operator+ ( const T &  rhs) const

Binary vector add.

Definition at line 636 of file Vec4Template.h.

◆ operator+() [2/2]

template<typename T >
const Vec4T< T > agx::Vec4T< T >::operator+ ( const Vec4T< T > &  rhs) const

Binary vector add.

Returns
a new Vec4 which is the sum of this Vec4 and rhs

Definition at line 604 of file Vec4Template.h.

◆ operator+=() [1/2]

template<typename T >
Vec4T< T > & agx::Vec4T< T >::operator+= ( const T &  rhs)

Unary vector add.

Slightly more efficient because no temporary intermediate object.

Definition at line 642 of file Vec4Template.h.

◆ operator+=() [2/2]

template<typename T >
Vec4T< T > & agx::Vec4T< T >::operator+= ( const Vec4T< T > &  rhs)

Unary vector add.

Slightly more efficient because no temporary intermediate object.

Definition at line 610 of file Vec4Template.h.

◆ operator-() [1/3]

template<typename T >
const Vec4T< T > agx::Vec4T< T >::operator-

Negation operator.

Returns the negative of the Vec4T.

Definition at line 668 of file Vec4Template.h.

◆ operator-() [2/3]

template<typename T >
const Vec4T< T > agx::Vec4T< T >::operator- ( const T &  rhs) const

Binary vector subtract.

Definition at line 652 of file Vec4Template.h.

◆ operator-() [3/3]

template<typename T >
const Vec4T< T > agx::Vec4T< T >::operator- ( const Vec4T< T > &  rhs) const

Binary vector subtract.

Definition at line 620 of file Vec4Template.h.

◆ operator-=() [1/2]

template<typename T >
Vec4T< T > & agx::Vec4T< T >::operator-= ( const T &  rhs)

Unary vector subtract.

Definition at line 658 of file Vec4Template.h.

◆ operator-=() [2/2]

template<typename T >
Vec4T< T > & agx::Vec4T< T >::operator-= ( const Vec4T< T > &  rhs)

Unary vector subtract.

Definition at line 626 of file Vec4Template.h.

◆ operator/()

template<typename T >
const Vec4T< T > agx::Vec4T< T >::operator/ ( T  rhs) const

Divide by scalar.

Definition at line 587 of file Vec4Template.h.

◆ operator/=()

template<typename T >
Vec4T< T > & agx::Vec4T< T >::operator/= ( T  rhs)
Returns
reference to the Vec4 Unary divided by scalar rhs.

Definition at line 593 of file Vec4Template.h.

◆ operator==()

template<typename T >
bool agx::Vec4T< T >::operator== ( const Vec4T< T > &  v) const

Equality test.

Definition at line 358 of file Vec4Template.h.

◆ operator[]() [1/2]

template<typename T >
T & agx::Vec4T< T >::operator[] ( size_t  i)
Returns
a reference to the i:th element

Definition at line 478 of file Vec4Template.h.

◆ operator[]() [2/2]

template<typename T >
const T & agx::Vec4T< T >::operator[] ( size_t  i) const
Returns
a reference to the i:th element

Definition at line 484 of file Vec4Template.h.

◆ operator|()

template<typename T >
const Vec4T< T > agx::Vec4T< T >::operator| ( const Vec4T< T > &  rhs) const
Returns
the result of an Element-wise-multiplication

Definition at line 561 of file Vec4Template.h.

◆ ptr() [1/2]

template<typename T >
T * agx::Vec4T< T >::ptr
Returns
a pointer to the data vector

Definition at line 442 of file Vec4Template.h.

◆ ptr() [2/2]

template<typename T >
const T * agx::Vec4T< T >::ptr
Returns
a const pointer to the data vector

Definition at line 448 of file Vec4Template.h.

◆ random() [1/2]

template<typename T >
Vec4T< T > agx::Vec4T< T >::random ( const Vec4T< T > &  min,
const Vec4T< T > &  max 
)
static
Returns
a random Vec4 in the range of [min..max]

Definition at line 732 of file Vec4Template.h.

References agx::max(), agx::min(), and agx::random().

◆ random() [2/2]

template<typename T >
Vec4T< T > agx::Vec4T< T >::random ( T  min,
T  max 
)
static
Returns
a random Vec4 in the range of [min..max]

Definition at line 726 of file Vec4Template.h.

References agx::max(), agx::min(), and agx::random().

◆ set() [1/4]

template<typename T >
void agx::Vec4T< T >::set ( const Vec4T< T > &  rhs)

Set the value of the vector with rhs.

Definition at line 469 of file Vec4Template.h.

◆ set() [2/4]

template<typename T >
void agx::Vec4T< T >::set ( T  val,
size_t  i 
)

Set the value of element i. Mainly for accessing vec4 in Lua.

Definition at line 714 of file Vec4Template.h.

◆ set() [3/4]

template<typename T >
void agx::Vec4T< T >::set ( T  value)

Set all elements of the vector with scalar value value.

Definition at line 463 of file Vec4Template.h.

◆ set() [4/4]

template<typename T >
void agx::Vec4T< T >::set ( T  x,
T  y,
T  z,
T  w 
)

Set the elements of the vector.

Definition at line 454 of file Vec4Template.h.

◆ w() [1/2]

template<typename T >
T & agx::Vec4T< T >::w
Returns
a reference to the 4:th element

Definition at line 508 of file Vec4Template.h.

Referenced by agx::QuatT< T >::QuatT(), agxRender::Color::a(), agx::Matrix4x4T< T >::postMult(), agx::Matrix4x4T< T >::preMult(), and agx::QuatT< T >::set().

◆ w() [2/2]

template<typename T >
T agx::Vec4T< T >::w
Returns
the 4:th element

Definition at line 531 of file Vec4Template.h.

◆ x() [1/2]

template<typename T >
T & agx::Vec4T< T >::x
Returns
a reference to the 1:st element

Definition at line 490 of file Vec4Template.h.

Referenced by agx::QuatT< T >::QuatT(), agx::Matrix4x4T< T >::postMult(), agx::Matrix4x4T< T >::preMult(), agxRender::Color::r(), and agx::QuatT< T >::set().

◆ x() [2/2]

template<typename T >
T agx::Vec4T< T >::x
Returns
the 1:st element

Definition at line 514 of file Vec4Template.h.

◆ y() [1/2]

template<typename T >
T & agx::Vec4T< T >::y
Returns
a reference to the 2:nd element

Definition at line 496 of file Vec4Template.h.

Referenced by agx::QuatT< T >::QuatT(), agxRender::Color::g(), agx::Matrix4x4T< T >::postMult(), agx::Matrix4x4T< T >::preMult(), and agx::QuatT< T >::set().

◆ y() [2/2]

template<typename T >
T agx::Vec4T< T >::y
Returns
the 2:nd element

Definition at line 520 of file Vec4Template.h.

◆ z() [1/2]

template<typename T >
T & agx::Vec4T< T >::z
Returns
a reference to the 3:rd element

Definition at line 502 of file Vec4Template.h.

Referenced by agx::QuatT< T >::QuatT(), agxRender::Color::b(), agx::Matrix4x4T< T >::postMult(), agx::Matrix4x4T< T >::preMult(), and agx::QuatT< T >::set().

◆ z() [2/2]

template<typename T >
T agx::Vec4T< T >::z
Returns
the 3:rd element

Definition at line 525 of file Vec4Template.h.


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