Itasca C++ Interface
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Related Symbols | List of all members
Vector2< T > Class Template Reference

2D vector utility class. More...

#include <vect.h>

Public Types

using CompType = T
 

Public Member Functions

 Vector2 ()
 Default constructor, no data initialization.
 
constexpr Vector2 (const Vector2< T > &v)
 Copy constructor.
 
constexpr Vector2 (const T &x, const T &y)
 Explicit constructor, from two components.
 
constexpr Vector2 (const T &t)
 Explicit contructor, each component is given value t.
 
constexpr const Vector2< T > & operator= (const Vector2< T > &in)
 
constexpr const T & x () const
 X component access.
 
constexpr const T & y () const
 Y component access.
 
constexpr const T & dof (unsigned u) const
 Access to degree of freedom u (0-1).
 
T & rx ()
 Reference access to x-component.
 
T & ry ()
 Reference access to y-component.
 
T & rdof (unsigned u)
 Reference accesss to degree-of-freedom u (0-1).
 
constexpr const T & operator[] (unsigned u) const
 Allow array like access by degree of freedom (0-1)
 
T & operator[] (unsigned u)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<std::size_t N>
constexpr decltype(auto) get () const
 
constexpr T fsum () const
 Manhattan norm.
 
constexpr T sum () const
 Sum of components.
 
constexpr T mag2 () const
 Square of the magnitude, or the dot product with itself.
 
constexpr T mag () const
 The magnitude.
 
constexpr T area () const
 Size of rectangle represented by x*y - can be negative.
 
constexpr T volume () const
 Volume of the rectangle assuming unit depth – same as area(), provided for 2D/3D compile compatibility with Cube.
 
constexpr T spread () const
 Assumes vector is being used to store a 1D extent– Returns max-min. (y-x).
 
constexpr Vector2< T > unit () const
 Unit vector - be sure vector is nonzero.
 
constexpr Vector2< T > abs () const
 Returns vector of absolute values of components.
 
constexpr void fill (const T &d)
 Fills all three components with value d.
 
constexpr T maxComp () const
 Returns the maximum component.
 
constexpr T minComp () const
 Returns the minimum component.
 
constexpr unsigned maxCompIndex () const
 Returns the max component index.
 
constexpr unsigned minCompIndex () const
 Returns the min component index.
 
constexpr const Vector2< T > & safeDivE (const Vector2< T > &v)
 "Safe" division operation - checks for zero and overflow.
 
constexpr const Vector2< T > safeDiv (const Vector2< T > &v)
 "Safe" division operation - checks for zero and overflow.
 
constexpr bool operator== (const Vector2< T > &v) const
 Comparison operator - no tolerance is used.
 
constexpr bool operator!= (const Vector2< T > &v) const
 Comparison operator - no tolerance is used.
 
constexpr bool operator< (const Vector2< T > &v) const
 Comparison operator, based on magnitude.
 
constexpr bool operator> (const Vector2< T > &v) const
 Comparison operator, based on magnitude.
 
constexpr const Vector2< T > & operator+= (const Vector2< T > &v)
 In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.
 
constexpr const Vector2< T > & operator-= (const Vector2< T > &v)
 In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.
 
constexpr const Vector2< T > & operator*= (const Vector2< T > &v)
 In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.
 
constexpr const Vector2< T > & operator*= (const T &t)
 In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.
 
constexpr const Vector2< T > & operator/= (const Vector2< T > &v)
 In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.
 
constexpr const Vector2< T > & operator/= (const T &t)
 In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.
 
constexpr Vector2< T > operator+ (const Vector2< T > &v) const
 Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.
 
constexpr Vector2< T > operator- (const Vector2< T > &v) const
 Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.
 
constexpr Vector2< T > operator* (const Vector2< T > &v) const
 Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.
 
constexpr Vector2< T > operator* (const T &t) const
 Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.
 
constexpr Vector2< T > operator/ (const Vector2< T > &v) const
 Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.
 
constexpr Vector2< T > operator/ (const T &t) const
 Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.
 
constexpr T operator| (const Vector2< T > &v) const
 Dot Product.
 
constexpr const Vector2< T > & expandToInclude (const T &t)
 Expands 1D range to include value t.
 
constexpr const Vector2< T > & expandToInclude (const Vector2< T > &v)
 Expands 1D range to include 1D range v.
 
constexpr Vector2< T > expandedToInclude (const T &t) const
 Returns 1D range expanded to include value t;.
 
constexpr Vector2< T > expandedToInclude (const Vector2< T > &v) const
 Returns 1D range expanded to include 1D range v.
 
constexpr bool contains (const T &t) const
 True if value t falls inside this 1D range (inclusive).
 

Static Public Member Functions

static Vector2< T > nothing ()
 Creates an "empty" vector, useful when Vector2 is used as a 1D extent.
 

Static Public Attributes

static constexpr uint32 vdim = 2
 

Related Symbols

(Note that these are not member symbols.)

POPWARNING typedef Vector2< double > DVect2
 
typedef Vector2< float > FVect2
 
typedef Vector2< int32 > IVect2
 
typedef Vector2< uint32 > UVect2
 
typedef Vector2< int64 > I64Vect2
 
typedef Vector2< uint64 > U64Vect2
 
template<class T >
constexpr DVect2 toDVect2 (const Vector2< T > &v)
 
template<class T >
constexpr FVect2 toFVect2 (const Vector2< T > &v)
 
template<class T >
constexpr IVect2 toIVect2 (const Vector2< T > &v)
 
template<class T >
constexpr UVect2 toUVect2 (const Vector2< T > &v)
 
template<class T >
constexpr Vector2< T > vmax (const Vector2< T > &v1, const Vector2< T > &v2)
 
template<class T >
constexpr Vector2< T > vmin (const Vector2< T > &v1, const Vector2< T > &v2)
 
template<class T >
constexpr Vector2< T > vsign (const Vector2< T > &v1, const Vector2< T > &v2)
 
template<class T >
Vector2< T > vceil (const Vector2< T > &v)
 
template<class T >
Vector2< T > vfloor (const Vector2< T > &v)
 
template<class T >
IVect2 vround (const Vector2< T > &v)
 

Detailed Description

template<class T>
class Vector2< T >

2D vector utility class.

Member Function Documentation

◆ operator*() [1/2]

template<class T >
constexpr Vector2< T > Vector2< T >::operator* ( const T & t) const
inlineconstexpr

Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.

◆ operator*() [2/2]

template<class T >
constexpr Vector2< T > Vector2< T >::operator* ( const Vector2< T > & v) const
inlineconstexpr

Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.

◆ operator*=() [1/2]

template<class T >
constexpr const Vector2< T > & Vector2< T >::operator*= ( const T & t)
inlineconstexpr

In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.

◆ operator*=() [2/2]

template<class T >
constexpr const Vector2< T > & Vector2< T >::operator*= ( const Vector2< T > & v)
inlineconstexpr

In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.

◆ operator-()

template<class T >
constexpr Vector2< T > Vector2< T >::operator- ( const Vector2< T > & v) const
inlineconstexpr

Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.

◆ operator-=()

template<class T >
constexpr const Vector2< T > & Vector2< T >::operator-= ( const Vector2< T > & v)
inlineconstexpr

In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.

◆ operator/() [1/2]

template<class T >
constexpr Vector2< T > Vector2< T >::operator/ ( const T & t) const
inlineconstexpr

Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.

◆ operator/() [2/2]

template<class T >
constexpr Vector2< T > Vector2< T >::operator/ ( const Vector2< T > & v) const
inlineconstexpr

Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.

◆ operator/=() [1/2]

template<class T >
constexpr const Vector2< T > & Vector2< T >::operator/= ( const T & t)
inlineconstexpr

In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.

◆ operator/=() [2/2]

template<class T >
constexpr const Vector2< T > & Vector2< T >::operator/= ( const Vector2< T > & v)
inlineconstexpr

In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done on a component basis.


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