AGX Dynamics 2.40.0.0
Loading...
Searching...
No Matches
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.
 
 Vec4T (const T v[4])
 Constructor, initialize elements with the specified scalars.
 
 Vec4T (const Vec3T< T > &v3, T w)
 Constructor, initialize the first three elements with v3 and the last with w.
 
 Vec4T (const Vec4T &copy)=default
 Copy constructor.
 
template<typename T2 >
 Vec4T (const Vec4T< T2 > &copy)
 Copy constructor for other types.
 
 Vec4T (T r)
 Constructor, fill all elements with scalar r.
 
 Vec4T (T x, T y, T z, T w)
 Constructor, initialize elements with the specified scalars.
 
Vec3T< T > asVec3 () const
 
void clamp (const Vec4T &min, const Vec4T &max)
 Clamp a vector between a lower and upper bound (per component).
 
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
 
maxComponent () const
 
size_t maxElement () const
 
minComponent () const
 
size_t minElement () const
 
Real normalize ()
 Normalize the vector so that it has length unity.
 
bool operator!= (const Vec4T &v) const
 In-equality test.
 
operator* (const Vec4T &rhs) const
 
const Vec4T operator* (T rhs) const
 
Vec4Toperator*= (T rhs)
 
const Vec4T operator+ (const T &rhs) const
 Binary vector add.
 
const Vec4T operator+ (const Vec4T &rhs) const
 Binary vector add.
 
Vec4Toperator+= (const T &rhs)
 Unary vector add.
 
Vec4Toperator+= (const Vec4T &rhs)
 Unary vector add.
 
const Vec4T operator- () const
 Negation operator.
 
const Vec4T operator- (const T &rhs) const
 Binary vector subtract.
 
const Vec4T operator- (const Vec4T &rhs) const
 Binary vector subtract.
 
Vec4Toperator-= (const T &rhs)
 Unary vector subtract.
 
Vec4Toperator-= (const Vec4T &rhs)
 Unary vector subtract.
 
const Vec4T operator/ (T rhs) const
 Divide by scalar.
 
Vec4Toperator/= (T rhs)
 
bool operator== (const Vec4T &v) const
 Equality test.
 
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.
 
void set (T value)
 Set all elements of the vector with scalar value value.
 
void set (T x, T y, T z, T w)
 Set the elements of the vector.
 
T & w ()
 
w () const
 
T & x ()
 
x () const
 
T & y ()
 
y () const
 
T & z ()
 
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 298 of file Vec4Template.h.

◆ Vec4T() [3/7]

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

Default constructor.

Definition at line 309 of file Vec4Template.h.

◆ Vec4T() [4/7]

template<typename T >
agx::Vec4T< T >::Vec4T ( 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 ( x,
y,
z,
w 
)

Constructor, initialize elements with the specified scalars.

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

◆ Vec4T() [7/7]

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

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

Definition at line 342 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 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(), 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 371 of file Vec4Template.h.

◆ 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.

◆ 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.

◆ 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().

◆ distance2() [2/5]

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

Definition at line 770 of file Vec4Template.h.

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

◆ distance2() [3/5]

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

Definition at line 782 of file Vec4Template.h.

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

◆ distance2() [4/5]

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

Definition at line 794 of file Vec4Template.h.

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

◆ distance2() [5/5]

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

Definition at line 806 of file Vec4Template.h.

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

◆ equalsZero()

template<typename T >
bool agx::Vec4T< T >::equalsZero
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
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
Returns
true if any of the elements is NAN

Definition at line 537 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 531 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 668 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 674 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 383 of file Vec4Template.h.

◆ maxElement()

template<typename T >
size_t agx::Vec4T< T >::maxElement
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
Returns
the smallest component (in absolute value).

Definition at line 377 of file Vec4Template.h.

◆ minElement()

template<typename T >
size_t agx::Vec4T< T >::minElement
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* ( rhs) const
Returns
a new Vec4 multiplied by scalar rhs.

Definition at line 564 of file Vec4Template.h.

◆ operator*=()

template<typename T >
Vec4T< T > & agx::Vec4T< T >::operator*= ( 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 T &  rhs) const

Binary vector add.

Definition at line 630 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 598 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 636 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 604 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 662 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 646 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 614 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 652 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 620 of file Vec4Template.h.

◆ operator/()

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

Divide by scalar.

Definition at line 581 of file Vec4Template.h.

◆ operator/=()

template<typename T >
Vec4T< T > & agx::Vec4T< T >::operator/= ( 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.

◆ 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
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 ( 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::max(), agx::min(), and agx::random().

◆ random() [2/2]

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

Definition at line 708 of file Vec4Template.h.

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

◆ set() [1/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.

◆ set() [2/3]

template<typename T >
void agx::Vec4T< T >::set ( 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 ( x,
y,
z,
w 
)

Set the elements of the vector.

Definition at line 448 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 502 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 525 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 484 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 508 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 490 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 514 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 496 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 519 of file Vec4Template.h.


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