AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
 
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
 
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...
 
void set (T val, size_t i)
 Set the value of element i. Mainly for accessing vec4 in Lua. 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

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

Definition at line 37 of file Vec4Template.h.

Constructor & Destructor Documentation

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

Copy constructor.

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.

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

Default constructor.

Definition at line 315 of file Vec4Template.h.

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.

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.

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.

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

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

Definition at line 720 of file Vec4Template.h.

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.

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

Referenced by agx::clamp().

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

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

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.

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

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

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

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

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

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

Definition at line 435 of file Vec4Template.h.

References agx::equalsZero().

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

References agx::isFinite().

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

Definition at line 543 of file Vec4Template.h.

References agx::isNaN().

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

Definition at line 537 of file Vec4Template.h.

References agx::isNaN().

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

Definition at line 674 of file Vec4Template.h.

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

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

Definition at line 680 of file Vec4Template.h.

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

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

Definition at line 389 of file Vec4Template.h.

References agx::max().

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

Definition at line 410 of file Vec4Template.h.

References agx::absolute().

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

Definition at line 383 of file Vec4Template.h.

References agx::min().

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

Definition at line 395 of file Vec4Template.h.

References agx::absolute().

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

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

In-equality test.

Definition at line 364 of file Vec4Template.h.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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

Negation operator.

Returns the negative of the Vec4T.

Definition at line 668 of file Vec4Template.h.

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

Unary vector subtract.

Definition at line 626 of file Vec4Template.h.

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

Unary vector subtract.

Definition at line 658 of file Vec4Template.h.

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

Divide by scalar.

Definition at line 587 of file Vec4Template.h.

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.

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

Equality test.

Definition at line 358 of file Vec4Template.h.

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.

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.

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.

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

Definition at line 442 of file Vec4Template.h.

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

Definition at line 448 of file Vec4Template.h.

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::random().

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::random().

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.

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.

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.

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.

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 agxRender::Color::a(), agx::Matrix4x4T< T >::postMult(), agx::Matrix4x4T< T >::preMult(), agx::QuatT< T >::QuatT(), and agx::QuatT< T >::set().

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

Definition at line 531 of file Vec4Template.h.

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::Matrix4x4T< T >::postMult(), agx::Matrix4x4T< T >::preMult(), agx::QuatT< T >::QuatT(), agxRender::Color::r(), and agx::QuatT< T >::set().

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

Definition at line 514 of file Vec4Template.h.

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 agxRender::Color::g(), agx::Matrix4x4T< T >::postMult(), agx::Matrix4x4T< T >::preMult(), agx::QuatT< T >::QuatT(), and agx::QuatT< T >::set().

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

Definition at line 520 of file Vec4Template.h.

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 agxRender::Color::b(), agx::Matrix4x4T< T >::postMult(), agx::Matrix4x4T< T >::preMult(), agx::QuatT< T >::QuatT(), and agx::QuatT< T >::set().

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

Definition at line 525 of file Vec4Template.h.


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