AGX Dynamics  2.37.2.0
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 (const Vec4T &copy)=default
 Copy constructor. More...
 
template<typename T2 >
 Vec4T (const Vec4T< T2 > &copy)
 Copy constructor for other types. More...
 
 Vec4T ()
 Default constructor. 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...
 
 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...
 
Vec3T< T > asVec3 () const
 
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
 
template<>
Real distance2 (const Vec4T &v2) const
 
template<>
Real distance2 (const Vec4T &v2) const
 
template<>
Real distance2 (const Vec4T &v2) const
 
template<>
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 Vec4T &rhs) const
 Binary vector add. More...
 
const Vec4T operator+ (const T &rhs) const
 Binary vector add. More...
 
Vec4T & operator+= (const Vec4T &rhs)
 Unary vector add. More...
 
Vec4T & operator+= (const T &rhs)
 Unary vector add. More...
 
const Vec4T operator- (const Vec4T &rhs) const
 Binary vector subtract. More...
 
const Vec4T operator- (const T &rhs) const
 Binary vector subtract. More...
 
const Vec4T operator- () const
 Negation operator. More...
 
Vec4T & operator-= (const Vec4T &rhs)
 Unary vector subtract. More...
 
Vec4T & operator-= (const T &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 (T x, T y, T z, T w)
 Set the elements of the vector. More...
 
void set (T value)
 Set all elements of the vector with scalar value value. More...
 
void set (const Vec4T &rhs)
 Set the value of the vector with rhs. 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 (T min, T max)
 
static Vec4T random (const Vec4T &min, const Vec4T &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 298 of file Vec4Template.h.

◆ Vec4T() [3/7]

◆ Vec4T() [4/7]

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

Constructor, fill all elements with scalar r.

Definition at line 318 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 324 of file Vec4Template.h.

References agx::Vec4T< T >::w(), agx::Vec4T< T >::x(), agx::Vec4T< T >::y(), and agx::Vec4T< T >::z().

◆ 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 333 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 342 of file Vec4Template.h.

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

Member Function Documentation

◆ asVec3()

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

Definition at line 702 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 419 of file Vec4Template.h.

References agx::clamp().

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 371 of file Vec4Template.h.

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

◆ 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 365 of file Vec4Template.h.

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

◆ distance()

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

Definition at line 681 of file Vec4Template.h.

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

◆ 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 762 of file Vec4Template.h.

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

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

◆ distance2() [2/5]

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

Definition at line 770 of file Vec4Template.h.

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

◆ distance2() [3/5]

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

Definition at line 782 of file Vec4Template.h.

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

◆ distance2() [4/5]

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

Definition at line 794 of file Vec4Template.h.

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

◆ distance2() [5/5]

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

Definition at line 806 of file Vec4Template.h.

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

◆ equalsZero()

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

Definition at line 429 of file Vec4Template.h.

References agx::equalsZero().

◆ isFinite()

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

Definition at line 543 of file Vec4Template.h.

References agx::isFinite().

◆ isNaN()

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

Definition at line 537 of file Vec4Template.h.

References agx::isNaN().

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

◆ isValid()

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

Definition at line 531 of file Vec4Template.h.

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

◆ length()

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

Definition at line 668 of file Vec4Template.h.

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

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

◆ length2()

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

Definition at line 674 of file Vec4Template.h.

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

◆ maxComponent()

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

Definition at line 383 of file Vec4Template.h.

References agx::max().

◆ maxElement()

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

Definition at line 404 of file Vec4Template.h.

References agx::absolute().

◆ minComponent()

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

Definition at line 377 of file Vec4Template.h.

References agx::min().

◆ minElement()

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

Definition at line 389 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 688 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 358 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 549 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 564 of file Vec4Template.h.

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

◆ 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 571 of file Vec4Template.h.

◆ operator+() [1/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 598 of file Vec4Template.h.

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

◆ operator+() [2/2]

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

Binary vector add.

Definition at line 630 of file Vec4Template.h.

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

◆ operator+=() [1/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 604 of file Vec4Template.h.

◆ operator+=() [2/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 636 of file Vec4Template.h.

◆ operator-() [1/3]

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

Binary vector subtract.

Definition at line 614 of file Vec4Template.h.

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

◆ operator-() [2/3]

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

Binary vector subtract.

Definition at line 646 of file Vec4Template.h.

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

◆ operator-() [3/3]

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

Negation operator.

Returns the negative of the Vec4T.

Definition at line 662 of file Vec4Template.h.

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

◆ operator-=() [1/2]

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

Unary vector subtract.

Definition at line 620 of file Vec4Template.h.

◆ operator-=() [2/2]

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

Unary vector subtract.

Definition at line 652 of file Vec4Template.h.

◆ operator/()

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

Divide by scalar.

Definition at line 581 of file Vec4Template.h.

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

◆ 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 587 of file Vec4Template.h.

◆ operator==()

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

Equality test.

Definition at line 352 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 472 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 478 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 555 of file Vec4Template.h.

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

◆ ptr() [1/2]

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

Definition at line 436 of file Vec4Template.h.

◆ ptr() [2/2]

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

Definition at line 442 of file Vec4Template.h.

◆ random() [1/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 708 of file Vec4Template.h.

References agx::random(), and agx::Vec4T< T >::Vec4T().

◆ random() [2/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 714 of file Vec4Template.h.

References agx::random(), and agx::Vec4T< T >::Vec4T().

◆ set() [1/3]

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 448 of file Vec4Template.h.

References agx::Vec4T< T >::w(), agx::Vec4T< T >::x(), agx::Vec4T< T >::y(), and agx::Vec4T< T >::z().

◆ set() [2/3]

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

Set all elements of the vector with scalar value value.

Definition at line 457 of file Vec4Template.h.

◆ set() [3/3]

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

Set the value of the vector with rhs.

Definition at line 463 of file Vec4Template.h.

◆ w() [1/2]

template<typename T >
T & agx::Vec4T< T >::w ( )

◆ w() [2/2]

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

Definition at line 525 of file Vec4Template.h.

◆ x() [1/2]

template<typename T >
T & agx::Vec4T< T >::x ( )

◆ x() [2/2]

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

Definition at line 508 of file Vec4Template.h.

◆ y() [1/2]

template<typename T >
T & agx::Vec4T< T >::y ( )

◆ y() [2/2]

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

Definition at line 514 of file Vec4Template.h.

◆ z() [1/2]

template<typename T >
T & agx::Vec4T< T >::z ( )

◆ z() [2/2]

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

Definition at line 519 of file Vec4Template.h.


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