AGX Dynamics 2.41.2.0
Loading...
Searching...
No Matches
agx::Vec3T< T > Class Template Reference

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

#include <Vec3Template.h>

Public Types

typedef T Type
 

Public Member Functions

 Vec3T ()
 Default constructor.
 
 Vec3T (const T v[3])
 
 Vec3T (const Vec2 &v2, T zz)
 
 Vec3T (const Vec3T &copy)=default
 Copy constructor.
 
 Vec3T (const Vec3T &copy, Real length)
 
 Vec3T (const Vec3T &copy, T value, size_t i)
 
template<typename T2 >
 Vec3T (const Vec3T< T2 > &copy)
 Copy constructor for other types.
 
 Vec3T (T r)
 
 Vec3T (T x, T y, T z)
 
void clamp (const Vec3T &min, const Vec3T &max)
 Clamp a vector between a lower and upper bound (per component).
 
const Vec3T cross (const Vec3T &rhs) const
 Cross product method.
 
Real distance (const Vec3T &v2) const
 Distance to another vector.
 
Real distance2 (const Vec3T &v2) const
 Squared distance to another vector.
 
Real distance2 (const Vec3T &v2) const
 
Real distance2 (const Vec3T &v2) const
 
Real distance2 (const Vec3T &v2) const
 
Real distance2 (const Vec3T &v2) const
 
bool equalsZero () const
 
Vec3T getPerpendicularUnitVector () const
 
Vec3T getPerpendicularUnitVector (const Vec3T &v2) const
 Return a unit vector perpendicular to this and another vector.
 
bool isFinite () const
 
bool isNaN () const
 
bool isValid () const
 
Real length () const
 Length of the vector = sqrt( vec .
 
Real length2 () const
 Length squared of the vector = vec .
 
maxComponent () const
 
size_t maxElement () const
 
minComponent () const
 
size_t minElement () const
 
Vec3T normal () const
 
Real normalize ()
 Normalize the vector so that it has length unity.
 
bool operator!= (const Vec3T &v) const
 In-equality test.
 
operator* (const Vec3T &rhs) const
 Dot product.
 
const Vec3T operator* (T rhs) const
 Multiply by scalar.
 
Vec3Toperator*= (T rhs)
 Unary multiply by scalar.
 
const Vec3T operator+ (const T &rhs) const
 Binary vector add.
 
const Vec3T operator+ (const Vec3T &rhs) const
 Binary vector add.
 
Vec3Toperator+= (const T &rhs)
 Unary vector add.
 
Vec3Toperator+= (const Vec3T &rhs)
 Unary vector add.
 
const Vec3T operator- () const
 Negation operator.
 
const Vec3T operator- (const T &rhs) const
 Binary vector subtract.
 
const Vec3T operator- (const Vec3T &rhs) const
 Binary vector subtract.
 
Vec3Toperator-= (const T &rhs)
 Unary vector subtract.
 
Vec3Toperator-= (const Vec3T &rhs)
 Unary vector subtract.
 
const Vec3T operator/ (T rhs) const
 Divide by scalar.
 
Vec3Toperator/= (T rhs)
 Unary divide by scalar.
 
bool operator== (const Vec3T &v) const
 Equality test.
 
T & operator[] (size_t i)
 
const T & operator[] (size_t i) const
 
const Vec3T operator^ (const Vec3T &rhs) const
 Cross product operator.
 
T * ptr ()
 
const T * ptr () const
 
void set (const Vec3T &rhs)
 
void set (T value)
 
void set (T x, T y, T z)
 
Real setLength (Real newLength)
 Scale the vector so that is has the specified length.
 
void store3 (T *storage) const
 Store the tree components to the given memory area.
 
T & x ()
 
x () const
 
T & y ()
 
y () const
 
T & z ()
 
z () const
 

Static Public Member Functions

static Vec3T AXIS (size_t i)
 
static Vec3T componentMax (const Vec3T &v1, const Vec3T &v2)
 Creates a new vector where each component is the maximum of this and the other vector.
 
static Vec3T componentMin (const Vec3T &v1, const Vec3T &v2)
 Creates a new vector where each component is the minimum of this and the other vector.
 
static Vec3T div (const Vec3T &lhs, const Vec3T &rhs)
 Element-wise-division.
 
static Vec3T mul (const Vec3T &lhs, const Vec3T &rhs)
 Element-wise-multiplication.
 
static Vec3T random (const Vec3T< T > &min, const Vec3T< T > &max)
 
static Vec3T random (T min=T(0), T max=T(1))
 
static Vec3T X_AXIS ()
 
static Vec3T Y_AXIS ()
 
static Vec3T Z_AXIS ()
 

Protected Attributes

m_data [4]
 

Detailed Description

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

A class holding 3 dimensional vectors and providing basic arithmetic.

The 3D vector class holds an internal representations of vectors which can include padding and so on. At this level of the API, the object is provided for user convenience. In the internal representation used by the solvers, 3D vectors may be concatenated into larger vector blocks as seems fit.

Definition at line 45 of file Vec3Template.h.

Member Typedef Documentation

◆ Type

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

Definition at line 48 of file Vec3Template.h.

Constructor & Destructor Documentation

◆ Vec3T() [1/9]

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

Copy constructor.

◆ Vec3T() [2/9]

template<typename T >
agx::Vec3T< T >::Vec3T ( const Vec3T< T > &  copy,
Real  length 
)

Definition at line 290 of file Vec3Template.h.

References agx::Vec3T< T >::m_data.

◆ Vec3T() [3/9]

template<typename T >
agx::Vec3T< T >::Vec3T ( const Vec3T< T > &  copy,
value,
size_t  i 
)

Definition at line 301 of file Vec3Template.h.

References agx::Vec3T< T >::m_data.

◆ Vec3T() [4/9]

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

Copy constructor for other types.

Definition at line 313 of file Vec3Template.h.

◆ Vec3T() [5/9]

template<typename T >
agx::Vec3T< T >::Vec3T

Default constructor.

Definition at line 323 of file Vec3Template.h.

◆ Vec3T() [6/9]

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

Definition at line 332 of file Vec3Template.h.

◆ Vec3T() [7/9]

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

Definition at line 339 of file Vec3Template.h.

◆ Vec3T() [8/9]

template<typename T >
agx::Vec3T< T >::Vec3T ( const T  v[3])
explicit

Definition at line 348 of file Vec3Template.h.

◆ Vec3T() [9/9]

template<typename T >
agx::Vec3T< T >::Vec3T ( const Vec2 v2,
zz 
)

Definition at line 357 of file Vec3Template.h.

Member Function Documentation

◆ AXIS()

template<typename T >
Vec3T< T > agx::Vec3T< T >::AXIS ( size_t  i)
static
Parameters
iThe axis to choose. 0, 1 or 2.
Returns
a vec3 defining an unit vector along the i-th axis.

Definition at line 789 of file Vec3Template.h.

◆ clamp()

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

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

Definition at line 433 of file Vec3Template.h.

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

Referenced by agx::clamp().

◆ componentMax()

template<typename T >
Vec3T< T > agx::Vec3T< T >::componentMax ( const Vec3T< T > &  v1,
const Vec3T< T > &  v2 
)
static

Creates a new vector where each component is the maximum of this and the other vector.

Definition at line 385 of file Vec3Template.h.

Referenced by agx::max().

◆ componentMin()

template<typename T >
Vec3T< T > agx::Vec3T< T >::componentMin ( const Vec3T< T > &  v1,
const Vec3T< T > &  v2 
)
static

Creates a new vector where each component is the minimum of this and the other vector.

Definition at line 379 of file Vec3Template.h.

Referenced by agx::min().

◆ cross()

template<typename T >
const Vec3T< T > agx::Vec3T< T >::cross ( const Vec3T< T > &  rhs) const

Cross product method.

Definition at line 561 of file Vec3Template.h.

References agx::Vec3T< T >::m_data.

Referenced by agx::OrientedFrictionModelImpl< T >::calculateTangentPlane().

◆ distance()

template<typename T >
Real agx::Vec3T< T >::distance ( const Vec3T< T > &  v2) const

Distance to another vector.

Definition at line 695 of file Vec3Template.h.

Referenced by agx::WireContactSpringConstraint::calculateViolation(), and agxSDK::findDistanceFromPointToLine().

◆ distance2() [1/5]

template<typename T >
Real agx::Vec3T< T >::distance2 ( const Vec3T< T > &  v2) const

Squared distance to another vector.

Definition at line 876 of file Vec3Template.h.

References agx::Vec3T< T >::length2(), and agx::Vec3T< T >::m_data.

Referenced by agxSDK::pointInsideCircle().

◆ distance2() [2/5]

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

Definition at line 883 of file Vec3Template.h.

References agx::Vec3T< T >::length2(), and agx::Vec3T< T >::m_data.

◆ distance2() [3/5]

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

Definition at line 893 of file Vec3Template.h.

References agx::Vec3T< T >::length2(), and agx::Vec3T< T >::m_data.

◆ distance2() [4/5]

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

Definition at line 903 of file Vec3Template.h.

References agx::Vec3T< T >::length2(), and agx::Vec3T< T >::m_data.

◆ distance2() [5/5]

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

Definition at line 913 of file Vec3Template.h.

References agx::Vec3T< T >::length2(), and agx::Vec3T< T >::m_data.

◆ div()

template<typename T >
Vec3T< T > agx::Vec3T< T >::div ( const Vec3T< T > &  lhs,
const Vec3T< T > &  rhs 
)
static

Element-wise-division.

Definition at line 576 of file Vec3Template.h.

◆ equalsZero()

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

Definition at line 441 of file Vec3Template.h.

References agx::equalsZero().

Referenced by agx::Vec3T< T >::getPerpendicularUnitVector().

◆ getPerpendicularUnitVector() [1/2]

template<typename T >
Vec3T< T > agx::Vec3T< T >::getPerpendicularUnitVector
Returns
an arbitrary unit vector perpendicular to this vector

Definition at line 732 of file Vec3Template.h.

References agx::absolute(), agx::Vec3T< T >::normalize(), and agx::Vec3T< T >::set().

Referenced by agx::SwingData::getSwingAxis().

◆ getPerpendicularUnitVector() [2/2]

template<typename T >
Vec3T< T > agx::Vec3T< T >::getPerpendicularUnitVector ( const Vec3T< T > &  v2) const

Return a unit vector perpendicular to this and another vector.

If the two vectors are parallel, an arbitrary perpendicular vector will be chosen.

Returns
a unit vector perpendicular to this and another vector.

Definition at line 759 of file Vec3Template.h.

References agx::Vec3T< T >::equalsZero(), and agx::Vec3T< T >::normalize().

◆ isFinite()

template<typename T >
bool agx::Vec3T< T >::isFinite

Definition at line 541 of file Vec3Template.h.

References agx::isFinite().

◆ isNaN()

template<typename T >
bool agx::Vec3T< T >::isNaN

Definition at line 535 of file Vec3Template.h.

References agx::isNaN().

◆ isValid()

◆ length()

◆ length2()

◆ maxComponent()

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

Definition at line 397 of file Vec3Template.h.

◆ maxElement()

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

Definition at line 418 of file Vec3Template.h.

References agx::absolute().

◆ minComponent()

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

Definition at line 391 of file Vec3Template.h.

◆ minElement()

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

Definition at line 403 of file Vec3Template.h.

References agx::absolute().

◆ mul()

template<typename T >
Vec3T< T > agx::Vec3T< T >::mul ( const Vec3T< T > &  lhs,
const Vec3T< T > &  rhs 
)
static

Element-wise-multiplication.

Definition at line 569 of file Vec3Template.h.

◆ normal()

template<typename T >
Vec3T< T > agx::Vec3T< T >::normal
Returns
a vec3 containing the normalized version of this vector.

Definition at line 722 of file Vec3Template.h.

References agx::Vec3T< T >::normalize().

◆ normalize()

◆ operator!=()

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

In-equality test.

Definition at line 372 of file Vec3Template.h.

References agx::Vec3T< T >::m_data.

◆ operator*() [1/2]

template<typename T >
T agx::Vec3T< T >::operator* ( const Vec3T< T > &  rhs) const

Dot product.

Definition at line 547 of file Vec3Template.h.

References agx::Vec3T< T >::m_data.

◆ operator*() [2/2]

template<typename T >
const Vec3T< T > agx::Vec3T< T >::operator* ( rhs) const

Multiply by scalar.

Definition at line 585 of file Vec3Template.h.

◆ operator*=()

template<typename T >
Vec3T< T > & agx::Vec3T< T >::operator*= ( rhs)

Unary multiply by scalar.

Definition at line 592 of file Vec3Template.h.

◆ operator+() [1/2]

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

Binary vector add.

Definition at line 647 of file Vec3Template.h.

◆ operator+() [2/2]

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

Binary vector add.

Definition at line 617 of file Vec3Template.h.

◆ operator+=() [1/2]

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

Unary vector add.

Slightly more efficient because no temporary intermediate object.

Definition at line 653 of file Vec3Template.h.

◆ operator+=() [2/2]

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

Unary vector add.

Slightly more efficient because no temporary intermediate object.

Definition at line 623 of file Vec3Template.h.

References agx::Vec3T< T >::m_data.

◆ operator-() [1/3]

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

Negation operator.

Returns the negative of the Vec3T.

Definition at line 677 of file Vec3Template.h.

◆ operator-() [2/3]

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

Binary vector subtract.

Definition at line 662 of file Vec3Template.h.

◆ operator-() [3/3]

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

Binary vector subtract.

Definition at line 632 of file Vec3Template.h.

◆ operator-=() [1/2]

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

Unary vector subtract.

Definition at line 668 of file Vec3Template.h.

◆ operator-=() [2/2]

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

Unary vector subtract.

Definition at line 638 of file Vec3Template.h.

References agx::Vec3T< T >::m_data.

◆ operator/()

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

Divide by scalar.

Definition at line 601 of file Vec3Template.h.

◆ operator/=()

template<typename T >
Vec3T< T > & agx::Vec3T< T >::operator/= ( rhs)

Unary divide by scalar.

Definition at line 607 of file Vec3Template.h.

◆ operator==()

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

Equality test.

Definition at line 366 of file Vec3Template.h.

References agx::Vec3T< T >::m_data.

◆ operator[]() [1/2]

template<typename T >
T & agx::Vec3T< T >::operator[] ( size_t  i)

Definition at line 481 of file Vec3Template.h.

◆ operator[]() [2/2]

template<typename T >
const T & agx::Vec3T< T >::operator[] ( size_t  i) const

Definition at line 487 of file Vec3Template.h.

◆ operator^()

template<typename T >
const Vec3T< T > agx::Vec3T< T >::operator^ ( const Vec3T< T > &  rhs) const

Cross product operator.

Definition at line 553 of file Vec3Template.h.

References agx::Vec3T< T >::m_data.

◆ ptr() [1/2]

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

Definition at line 447 of file Vec3Template.h.

Referenced by agx::innerProd_6(), and agx::mult().

◆ ptr() [2/2]

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

Definition at line 453 of file Vec3Template.h.

◆ random() [1/2]

template<typename T >
Vec3T< T > agx::Vec3T< T >::random ( const Vec3T< T > &  min,
const Vec3T< T > &  max 
)
static

Definition at line 803 of file Vec3Template.h.

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

◆ random() [2/2]

template<typename T >
Vec3T< T > agx::Vec3T< T >::random ( min = T(0),
max = T(1) 
)
static

Definition at line 797 of file Vec3Template.h.

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

◆ set() [1/3]

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

Definition at line 473 of file Vec3Template.h.

References agx::Vec3T< T >::m_data.

◆ set() [2/3]

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

Definition at line 467 of file Vec3Template.h.

◆ set() [3/3]

◆ setLength()

template<typename T >
Real agx::Vec3T< T >::setLength ( Real  newLength)

Scale the vector so that is has the specified length.

Definition at line 707 of file Vec3Template.h.

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

◆ store3()

template<typename T >
void agx::Vec3T< T >::store3 ( T *  storage) const

Store the tree components to the given memory area.

Definition at line 810 of file Vec3Template.h.

◆ x() [1/2]

◆ x() [2/2]

template<typename T >
T agx::Vec3T< T >::x

Definition at line 511 of file Vec3Template.h.

◆ X_AXIS()

template<typename T >
Vec3T< T > agx::Vec3T< T >::X_AXIS
static
Returns
a vec3 defining a vector along the x-axis

Definition at line 771 of file Vec3Template.h.

◆ y() [1/2]

◆ y() [2/2]

template<typename T >
T agx::Vec3T< T >::y

Definition at line 517 of file Vec3Template.h.

◆ Y_AXIS()

template<typename T >
Vec3T< T > agx::Vec3T< T >::Y_AXIS
static
Returns
a vec3 defining a vector along the y-axis

Definition at line 777 of file Vec3Template.h.

◆ z() [1/2]

◆ z() [2/2]

template<typename T >
T agx::Vec3T< T >::z

Definition at line 523 of file Vec3Template.h.

◆ Z_AXIS()

template<typename T >
Vec3T< T > agx::Vec3T< T >::Z_AXIS
static
Returns
a vec3 defining a vector along the z-axis

Definition at line 783 of file Vec3Template.h.

Member Data Documentation

◆ m_data


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