SLProject 4.0.000
SLVec2< T > Class Template Reference

2D vector template class for standard 2D vector algebra. More...

#include <SLVec2.h>

Public Member Functions

 SLVec2 ()
 
 SLVec2 (const T X, const T Y)
 
 SLVec2 (const T v[2])
 
 SLVec2 (const SLVec2 &v)
 
void set (const T X, const T Y)
 
void set (const T v[2])
 
void set (const SLVec2 &v)
 
SLbool operator== (const SLVec2 &v) const
 
SLbool operator!= (const SLVec2 &v) const
 
SLbool operator<= (const SLVec2 &v) const
 
SLbool operator>= (const SLVec2 &v) const
 
SLbool operator< (const SLVec2 &v) const
 
SLbool operator> (const SLVec2 &v) const
 
SLbool operator<= (const T v) const
 
SLbool operator>= (const T v) const
 
SLbool operator< (const T v) const
 
SLbool operator> (const T v) const
 
SLVec2 operator+ (const SLVec2 &v) const
 
SLVec2 operator- (const SLVec2 &v) const
 
SLVec2 operator- () const
 
operator* (const SLVec2 &v) const
 
SLVec2 operator* (const T s) const
 
SLVec2 operator/ (const T s) const
 
SLVec2 operator& (const SLVec2 &v) const
 
SLVec2operator= (const SLVec2 &v)
 
SLVec2operator+= (const SLVec2 &v)
 
SLVec2operator-= (const SLVec2 &v)
 
SLVec2operator*= (const T s)
 
SLVec2operator/= (const T s)
 
SLVec2operator&= (const SLVec2 &v)
 
void add (const SLVec2 &a, const SLVec2 &b)
 
void sub (const SLVec2 &a, const SLVec2 &b)
 
void scale (const T s)
 
dot (const SLVec2 &v)
 
length () const
 
lengthSqr () const
 
SLVec2normalize ()
 
void clampMinMax (const T min, const T max)
 
void toPolar (T &r, T &phiRAD)
 Calculates polar coords with radius & angle phi in radians (-pi < phi < pi) More...
 
void fromPolar (T r, T phiRAD)
 Calculates the vector from polar coords r & phi in radians (-pi < phi < pi) More...
 
SLVec2 barycentricCoords (SLVec2 A, SLVec2 B, SLVec2 C)
 Calculate the barycentric coordinate uv of the point within a triangle ABC. More...
 
diff (const SLVec2 &v)
 Calculate the absolute to the vector v. More...
 
void setMin (const SLVec2 &v)
 
void setMax (const SLVec2 &v)
 
SLbool isZero ()
 
void print (const char *str=nullptr)
 
SLstring toString (SLstring delimiter=", ", int decimals=2)
 Conversion to string. More...
 

Public Attributes

union {
   struct {
      T   x
 
      T   y
 
   } 
 
   struct {
      T   comp [2]
 
   } 
 
}; 
 

Static Public Attributes

static SLVec2 ZERO = SLVec2<T>(0,0)
 

Friends

SLVec2 operator* (T s, const SLVec2 &v)
 
std::ostream & operator<< (std::ostream &output, const SLVec2 &v)
 

Detailed Description

template<class T>
class SLVec2< T >

2D vector template class for standard 2D vector algebra.

2D vector template class and type definitions for 2D vectors;
Use SLVec2f for a specific float type vector
Use SLVec2d for a specific double type vector
Use SLVec2r for a precision independent real type.

Constructor & Destructor Documentation

◆ SLVec2() [1/4]

template<class T >
SLVec2< T >::SLVec2 ( )
inline

◆ SLVec2() [2/4]

template<class T >
SLVec2< T >::SLVec2 ( const T  X,
const T  Y 
)
inline

◆ SLVec2() [3/4]

template<class T >
SLVec2< T >::SLVec2 ( const T  v[2])
inline

◆ SLVec2() [4/4]

template<class T >
SLVec2< T >::SLVec2 ( const SLVec2< T > &  v)
inline

Member Function Documentation

◆ add()

template<class T >
void SLVec2< T >::add ( const SLVec2< T > &  a,
const SLVec2< T > &  b 
)
inline

◆ barycentricCoords()

template<class T >
SLVec2 SLVec2< T >::barycentricCoords ( SLVec2< T >  A,
SLVec2< T >  B,
SLVec2< T >  C 
)
inline

Calculate the barycentric coordinate uv of the point within a triangle ABC.

◆ clampMinMax()

template<class T >
void SLVec2< T >::clampMinMax ( const T  min,
const T  max 
)
inline

◆ diff()

template<class T >
T SLVec2< T >::diff ( const SLVec2< T > &  v)
inline

Calculate the absolute to the vector v.

◆ dot()

template<class T >
T SLVec2< T >::dot ( const SLVec2< T > &  v)
inline

◆ fromPolar()

template<class T >
void SLVec2< T >::fromPolar ( r,
phiRAD 
)
inline

Calculates the vector from polar coords r & phi in radians (-pi < phi < pi)

◆ isZero()

template<class T >
SLbool SLVec2< T >::isZero ( )
inline

◆ length()

template<class T >
T SLVec2< T >::length ( ) const
inline

◆ lengthSqr()

template<class T >
T SLVec2< T >::lengthSqr ( ) const
inline

◆ normalize()

template<class T >
SLVec2 & SLVec2< T >::normalize ( )
inline

◆ operator!=()

template<class T >
SLbool SLVec2< T >::operator!= ( const SLVec2< T > &  v) const
inline

◆ operator&()

template<class T >
SLVec2 SLVec2< T >::operator& ( const SLVec2< T > &  v) const
inline

◆ operator&=()

template<class T >
SLVec2 & SLVec2< T >::operator&= ( const SLVec2< T > &  v)
inline

◆ operator*() [1/2]

template<class T >
T SLVec2< T >::operator* ( const SLVec2< T > &  v) const
inline

◆ operator*() [2/2]

template<class T >
SLVec2 SLVec2< T >::operator* ( const T  s) const
inline

◆ operator*=()

template<class T >
SLVec2 & SLVec2< T >::operator*= ( const T  s)
inline

◆ operator+()

template<class T >
SLVec2 SLVec2< T >::operator+ ( const SLVec2< T > &  v) const
inline

◆ operator+=()

template<class T >
SLVec2 & SLVec2< T >::operator+= ( const SLVec2< T > &  v)
inline

◆ operator-() [1/2]

template<class T >
SLVec2 SLVec2< T >::operator- ( ) const
inline

◆ operator-() [2/2]

template<class T >
SLVec2 SLVec2< T >::operator- ( const SLVec2< T > &  v) const
inline

◆ operator-=()

template<class T >
SLVec2 & SLVec2< T >::operator-= ( const SLVec2< T > &  v)
inline

◆ operator/()

template<class T >
SLVec2 SLVec2< T >::operator/ ( const T  s) const
inline

◆ operator/=()

template<class T >
SLVec2 & SLVec2< T >::operator/= ( const T  s)
inline

◆ operator<() [1/2]

template<class T >
SLbool SLVec2< T >::operator< ( const SLVec2< T > &  v) const
inline

◆ operator<() [2/2]

template<class T >
SLbool SLVec2< T >::operator< ( const T  v) const
inline

◆ operator<=() [1/2]

template<class T >
SLbool SLVec2< T >::operator<= ( const SLVec2< T > &  v) const
inline

◆ operator<=() [2/2]

template<class T >
SLbool SLVec2< T >::operator<= ( const T  v) const
inline

◆ operator=()

template<class T >
SLVec2 & SLVec2< T >::operator= ( const SLVec2< T > &  v)
inline

◆ operator==()

template<class T >
SLbool SLVec2< T >::operator== ( const SLVec2< T > &  v) const
inline

◆ operator>() [1/2]

template<class T >
SLbool SLVec2< T >::operator> ( const SLVec2< T > &  v) const
inline

◆ operator>() [2/2]

template<class T >
SLbool SLVec2< T >::operator> ( const T  v) const
inline

◆ operator>=() [1/2]

template<class T >
SLbool SLVec2< T >::operator>= ( const SLVec2< T > &  v) const
inline

◆ operator>=() [2/2]

template<class T >
SLbool SLVec2< T >::operator>= ( const T  v) const
inline

◆ print()

template<class T >
void SLVec2< T >::print ( const char *  str = nullptr)
inline

◆ scale()

template<class T >
void SLVec2< T >::scale ( const T  s)
inline

◆ set() [1/3]

template<class T >
void SLVec2< T >::set ( const SLVec2< T > &  v)
inline

◆ set() [2/3]

template<class T >
void SLVec2< T >::set ( const T  v[2])
inline

◆ set() [3/3]

template<class T >
void SLVec2< T >::set ( const T  X,
const T  Y 
)
inline

◆ setMax()

template<class T >
void SLVec2< T >::setMax ( const SLVec2< T > &  v)
inline

◆ setMin()

template<class T >
void SLVec2< T >::setMin ( const SLVec2< T > &  v)
inline

◆ sub()

template<class T >
void SLVec2< T >::sub ( const SLVec2< T > &  a,
const SLVec2< T > &  b 
)
inline

◆ toPolar()

template<class T >
void SLVec2< T >::toPolar ( T &  r,
T &  phiRAD 
)
inline

Calculates polar coords with radius & angle phi in radians (-pi < phi < pi)

◆ toString()

template<class T >
SLstring SLVec2< T >::toString ( SLstring  delimiter = ", ",
int  decimals = 2 
)
inline

Conversion to string.

Friends And Related Function Documentation

◆ operator*

template<class T >
SLVec2 operator* ( s,
const SLVec2< T > &  v 
)
friend

◆ operator<<

template<class T >
std::ostream & operator<< ( std::ostream &  output,
const SLVec2< T > &  v 
)
friend

Member Data Documentation

◆ 

union { ... } SLVec2< T >::@12

◆ comp

template<class T >
T SLVec2< T >::comp[2]

◆ x

template<class T >
T SLVec2< T >::x

◆ y

template<class T >
T SLVec2< T >::y

◆ ZERO

template<class T >
SLVec2< T > SLVec2< T >::ZERO = SLVec2<T>(0,0)
static

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