Atoms Crowd  7.0.0
Vec2< T > Class Template Reference

#include <ImathVec.h>

Public Types

typedef T BaseType
 

Public Member Functions

ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T & operator[] (int i) noexcept
 Element access by index.

 
constexpr ATOMSMATH_HOSTDEVICE const T & operator[] (int i) const noexcept
 Element access by index.

 
short length () const noexcept=delete
 
const Vec2< short > & normalize () noexcept=delete
 
const Vec2< short > & normalizeExc ()=delete
 
const Vec2< short > & normalizeNonNull () noexcept=delete
 
Vec2< short > normalized () const noexcept=delete
 
Vec2< short > normalizedExc () const=delete
 
Vec2< short > normalizedNonNull () const noexcept=delete
 
int length () const noexcept=delete
 
const Vec2< int > & normalize () noexcept=delete
 
const Vec2< int > & normalizeExc ()=delete
 
const Vec2< int > & normalizeNonNull () noexcept=delete
 
Vec2< int > normalized () const noexcept=delete
 
Vec2< int > normalizedExc () const=delete
 
Vec2< int > normalizedNonNull () const noexcept=delete
 
template<class S >
constexpr Vec2 (const Vec2< S > &v) noexcept
 
template<class S >
void setValue (S a, S b) noexcept
 
template<class S >
void setValue (const Vec2< S > &v) noexcept
 
template<class S >
void getValue (S &a, S &b) const noexcept
 
template<class S >
void getValue (Vec2< S > &v) const noexcept
 
template<class S >
constexpr bool operator== (const Vec2< S > &v) const noexcept
 
template<class S >
constexpr bool operator!= (const Vec2< S > &v) const noexcept
 
Constructors and Assignment
ATOMSMATH_HOSTDEVICE Vec2 () noexcept
 Uninitialized by default.
 
constexpr ATOMSMATH_HOSTDEVICE Vec2 (T a) noexcept
 Initialize to a scalar (a,a)
 
constexpr ATOMSMATH_HOSTDEVICE Vec2 (T a, T b) noexcept
 Initialize to given elements (a,b)
 
constexpr ATOMSMATH_HOSTDEVICE Vec2 (const Vec2 &v) noexcept
 Copy constructor.
 
template<class S >
constexpr ATOMSMATH_HOSTDEVICE Vec2 (const Vec2< S > &v) noexcept
 Construct from Vec2 of another base type.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Vec2operator= (const Vec2 &v) noexcept
 Assignment.
 
 ~Vec2 () noexcept=default
 Destructor.
 
Compatibility with Sb
template<class S >
ATOMSMATH_HOSTDEVICE void setValue (S a, S b) noexcept
 Set the value.
 
template<class S >
ATOMSMATH_HOSTDEVICE void setValue (const Vec2< S > &v) noexcept
 Set the value.
 
template<class S >
ATOMSMATH_HOSTDEVICE void getValue (S &a, S &b) const noexcept
 Return the value in a and b
 
template<class S >
ATOMSMATH_HOSTDEVICE void getValue (Vec2< S > &v) const noexcept
 Return the value in v
 
ATOMSMATH_HOSTDEVICE T * getValue () noexcept
 Return a raw pointer to the array of values.
 
ATOMSMATH_HOSTDEVICE const T * getValue () const noexcept
 Return a raw pointer to the array of values.
 
Arithmetic and Comparison
template<class S >
constexpr ATOMSMATH_HOSTDEVICE bool operator== (const Vec2< S > &v) const noexcept
 Equality.
 
template<class S >
constexpr ATOMSMATH_HOSTDEVICE bool operator!= (const Vec2< S > &v) const noexcept
 Inequality.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool equalWithAbsError (const Vec2< T > &v, T e) const noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool equalWithRelError (const Vec2< T > &v, T e) const noexcept
 
constexpr ATOMSMATH_HOSTDEVICE T dot (const Vec2 &v) const noexcept
 Dot product.
 
constexpr ATOMSMATH_HOSTDEVICE T operator^ (const Vec2 &v) const noexcept
 Dot product.
 
constexpr ATOMSMATH_HOSTDEVICE T cross (const Vec2 &v) const noexcept
 
constexpr ATOMSMATH_HOSTDEVICE T operator% (const Vec2 &v) const noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Vec2operator+= (const Vec2 &v) noexcept
 Component-wise addition.
 
constexpr ATOMSMATH_HOSTDEVICE Vec2 operator+ (const Vec2 &v) const noexcept
 Component-wise addition.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Vec2operator-= (const Vec2 &v) noexcept
 Component-wise subtraction.
 
constexpr ATOMSMATH_HOSTDEVICE Vec2 operator- (const Vec2 &v) const noexcept
 Component-wise subtraction.
 
constexpr ATOMSMATH_HOSTDEVICE Vec2 operator- () const noexcept
 Component-wise multiplication by -1.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Vec2negate () noexcept
 Component-wise multiplication by -1.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Vec2operator*= (const Vec2 &v) noexcept
 Component-wise multiplication.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Vec2operator*= (T a) noexcept
 Component-wise multiplication.
 
constexpr ATOMSMATH_HOSTDEVICE Vec2 operator* (const Vec2 &v) const noexcept
 Component-wise multiplication.
 
constexpr ATOMSMATH_HOSTDEVICE Vec2 operator* (T a) const noexcept
 Component-wise multiplication.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Vec2operator/= (const Vec2 &v) noexcept
 Component-wise division.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Vec2operator/= (T a) noexcept
 Component-wise division.
 
constexpr ATOMSMATH_HOSTDEVICE Vec2 operator/ (const Vec2 &v) const noexcept
 Component-wise division.
 
constexpr ATOMSMATH_HOSTDEVICE Vec2 operator/ (T a) const noexcept
 Component-wise division.
 
Query and Manipulation
ATOMSMATH_HOSTDEVICE T length () const noexcept
 Return the Euclidean norm.
 
constexpr ATOMSMATH_HOSTDEVICE T length2 () const noexcept
 
ATOMSMATH_HOSTDEVICE const Vec2normalize () noexcept
 Normalize in place. If length()==0, return a null vector.
 
const Vec2normalizeExc ()
 Normalize in place. If length()==0, throw an exception.
 
ATOMSMATH_HOSTDEVICE const Vec2normalizeNonNull () noexcept
 
ATOMSMATH_HOSTDEVICE Vec2< T > normalized () const noexcept
 Return a normalized vector. Does not modify *this.
 
Vec2< T > normalizedExc () const
 
ATOMSMATH_HOSTDEVICE Vec2< T > normalizedNonNull () const noexcept
 

Static Public Member Functions

constexpr static ATOMSMATH_HOSTDEVICE unsigned int dimensions () noexcept
 Return the number of dimensions, i.e. 2.
 
Numeric Limits
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeLowest () noexcept
 Largest possible negative value.
 
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeMax () noexcept
 Largest possible positive value.
 
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeSmallest () noexcept
 Smallest possible positive value.
 
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeEpsilon () noexcept
 Smallest possible e for which 1+e != 1.
 

Public Attributes

Direct access to elements
x
 
y
 

Detailed Description

template<class T>
class Vec2< T >

2-element vector

Member Typedef Documentation

◆ BaseType

template<class T >
typedef T Vec2< T >::BaseType

The base type: In templates that accept a parameter V, you can refer to T as V::BaseType

Member Function Documentation

◆ cross()

template<class T >
constexpr T Vec2< T >::cross ( const Vec2< T > &  v) const
inlineconstexprnoexcept

Right-handed cross product, i.e. z component of Vec3 (this->x, this->y, 0) % Vec3 (v.x, v.y, 0)

◆ equalWithAbsError()

template<class T >
ATOMSMATH_CONSTEXPR14 bool Vec2< T >::equalWithAbsError ( const Vec2< T > &  v,
e 
) const
inlinenoexcept

Compare two matrices and test if they are "approximately equal":

Returns
True if the coefficients of this and m are the same with an absolute error of no more than e, i.e., for all i, j:

abs (this[i][j] - m[i][j]) <= e

◆ equalWithRelError()

template<class T >
ATOMSMATH_CONSTEXPR14 bool Vec2< T >::equalWithRelError ( const Vec2< T > &  v,
e 
) const
inlinenoexcept

Compare two matrices and test if they are "approximately equal":

Returns
True if the coefficients of this and m are the same with a relative error of no more than e, i.e., for all i, j:

abs (this[i] - v[i][j]) <= e * abs (this[i][j])

◆ length2()

template<class T >
constexpr T Vec2< T >::length2
inlineconstexprnoexcept

Return the square of the Euclidean norm, i.e. the dot product with itself.

◆ normalizedExc()

template<class T >
Vec2< T > Vec2< T >::normalizedExc
inline

Return a normalized vector. Does not modify *this. Throw an exception if length()==0.

◆ normalizedNonNull()

template<class T >
Vec2< T > Vec2< T >::normalizedNonNull
inlinenoexcept

Return a normalized vector. Does not modify *this, and does not check for length()==0. Slightly faster than the other normalization routines, but if v.length() is 0.0, the result is undefined.

◆ normalizeNonNull()

template<class T >
const Vec2< T > & Vec2< T >::normalizeNonNull
inlinenoexcept

Normalize without any checks for length()==0. Slightly faster than the other normalization routines, but if v.length() is 0.0, the result is undefined.

◆ operator%()

template<class T >
constexpr T Vec2< T >::operator% ( const Vec2< T > &  v) const
inlineconstexprnoexcept

Right-handed cross product, i.e. z component of Vec3 (this->x, this->y, 0) % Vec3 (v.x, v.y, 0)


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