Public Types | Public Member Functions | Static Public Member Functions | Public Attributes

CL_Vec2< Type > Class Template Reference
[clanCore Math]

2D vector More...

#include <vec2.h>

Inheritance diagram for CL_Vec2< Type >:
Inheritance graph
[legend]

List of all members.

Public Types

typedef Type datatype

Public Member Functions

 CL_Vec2 ()
template<>
 CL_Vec2 (const CL_Vec2< int > &copy)
template<>
 CL_Vec2 (const CL_Vec2< double > &copy)
template<>
 CL_Vec2 (const CL_Vec2< float > &copy)
template<>
 CL_Vec2 (const CL_Vec2< int > &copy)
template<>
 CL_Vec2 (const CL_Vec2< double > &copy)
template<>
 CL_Vec2 (const CL_Vec2< float > &copy)
template<>
 CL_Vec2 (const CL_Vec2< int > &copy)
template<>
 CL_Vec2 (const CL_Vec2< double > &copy)
template<>
 CL_Vec2 (const CL_Vec2< float > &copy)
template<>
 CL_Vec2 (const CL_Vec2< int > &copy)
template<>
 CL_Vec2 (const CL_Vec2< double > &copy)
template<>
 CL_Vec2 (const CL_Vec2< float > &copy)
template<>
 CL_Vec2 (const CL_Vec2< int > &copy)
template<>
 CL_Vec2 (const CL_Vec2< double > &copy)
template<>
 CL_Vec2 (const CL_Vec2< float > &copy)
 CL_Vec2 (const CL_Vec2< int > &copy)
 CL_Vec2 (const CL_Vec2< float > &copy)
 CL_Vec2 (const CL_Vec2< double > &copy)
 CL_Vec2 (const CL_Pointx< double > &point)
 CL_Vec2 (const CL_Pointx< float > &point)
 CL_Vec2 (const CL_Pointx< int > &point)
 CL_Vec2 (const Type *array_xy)
 CL_Vec2 (const Type &p1, const Type &p2=0)
 CL_Vec2 (const CL_Vec4< Type > &copy)
 CL_Vec2 (const CL_Vec3< Type > &copy)
 CL_Vec2 (const CL_Vec1< Type > &copy)
Attributes

Type length () const
 Returns the length (magnitude) of this vector.
CL_Vec2< Type > & normalize ()
 Normalizes this vector.
Type dot (const CL_Vec2< Type > &vector) const
 Dot products this vector with an other vector.
CL_Angle angle (const CL_Vec2< Type > &vector) const
 Calculate the angle between this vector and an other vector.
CL_Angle angle_relative (const CL_Vec2< Type > &vector) const
 Calculate the angle between this vector relative to another vector.
Type distance (const CL_Vec2< Type > &vector) const
 Calculate the distance between this vector and an other vector.
CL_Vec2< Type > & round ()
 Rounds all components of this vector.
CL_Vec2< Type > & rotate (const CL_Vec2< Type > &hotspot, const CL_Angle &angle)
 Rotate this vector around another point.
Type round_value (float value) const
 Rounds a value for the datatype.
Operators

const Type & operator[] (unsigned int i) const
Type & operator[] (unsigned int i)
 operator Type * ()
 operator Type *const () const
void operator+= (const CL_Vec2< Type > &vector)
 += operator.
void operator+= (Type value)
 += operator.
CL_Vec2< Type > operator+ (const CL_Vec2< Type > &vector) const
 + operator.
CL_Vec2< Type > operator+ (Type value) const
 + operator.
void operator-= (const CL_Vec2< Type > &vector)
 -= operator.
void operator-= (Type value)
 -= operator.
CL_Vec2< Type > operator- (const CL_Vec2< Type > &vector) const
 
  • operator.

CL_Vec2< Type > operator- (Type value) const
 
  • operator.

CL_Vec2< Type > operator- () const
 
  • operator.

void operator*= (const CL_Vec2< Type > &vector)
 *= operator.
void operator*= (Type value)
 *= operator.
CL_Vec2< Type > operator* (const CL_Vec2< Type > &vector) const
 * operator.
CL_Vec2< Type > operator* (Type value) const
 * operator.
void operator/= (const CL_Vec2< Type > &vector)
 /= operator.
void operator/= (Type value)
 /= operator.
CL_Vec2< Type > operator/ (const CL_Vec2< Type > &vector) const
 / operator.
CL_Vec2< Type > operator/ (Type value) const
 / operator.
CL_Vec2< Type > & operator= (const CL_Vec2< Type > &vector)
 = operator.
bool operator== (const CL_Vec2< Type > &vector) const
 == operator.
bool operator!= (const CL_Vec2< Type > &vector) const
 != operator.

Static Public Member Functions

static CL_Pointx< Type > calc_origin (CL_Origin origin, const CL_Sizex< Type > &size)
 Returns the anchor point for the origin within the dimensions of the size structure.
static Type dot (const CL_Vec2< Type > &vector_1, const CL_Vec2< Type > &vector_2)
 Dot products a vector with an other vector.
static CL_Vec2< Type > normalize (const CL_Vec2< Type > &vector)
 Normalizes a vector.
static CL_Vec2< Type > rotate (const CL_Vec2< Type > &vector, const CL_Vec2< Type > &hotspot, const CL_Angle &angle)
 Rotate a vector around another point.
static CL_Vec2< Type > round (const CL_Vec2< Type > &vector)
 Rounds all components on a vector.

Public Attributes

union {
   Type   g
   Type   t
   Type   y
}; 
union {
   Type   r
   Type   s
   Type   x
}; 

Detailed Description

template<typename Type>
class CL_Vec2< Type >

2D vector

These vector templates are defined for:
char (CL_Vec2c), unsigned char (CL_Vec2uc), short (CL_Vec2s),
unsigned short (CL_Vec2us), int (CL_Vec2i), unsigned int (CL_Vec2ui), float (CL_Vec2f), double (CL_Vec2d)


Member Typedef Documentation

template<typename Type>
typedef Type CL_Vec2< Type >::datatype

Constructor & Destructor Documentation

template<typename Type>
CL_Vec2< Type >::CL_Vec2 (  )  [inline]
template<typename Type>
CL_Vec2< Type >::CL_Vec2 ( const CL_Vec1< Type > &  copy  )  [inline]
template<typename Type>
CL_Vec2< Type >::CL_Vec2 ( const CL_Vec3< Type > &  copy  )  [inline]
template<typename Type>
CL_Vec2< Type >::CL_Vec2 ( const CL_Vec4< Type > &  copy  )  [inline]
template<typename Type>
CL_Vec2< Type >::CL_Vec2 ( const Type &  p1,
const Type &  p2 = 0 
) [inline]
template<typename Type>
CL_Vec2< Type >::CL_Vec2 ( const Type *  array_xy  )  [inline]
template<typename Type>
CL_Vec2< Type >::CL_Vec2 ( const CL_Pointx< int > &  point  ) 
template<typename Type>
CL_Vec2< Type >::CL_Vec2 ( const CL_Pointx< float > &  point  ) 
template<typename Type>
CL_Vec2< Type >::CL_Vec2 ( const CL_Pointx< double > &  point  ) 
template<typename Type>
CL_Vec2< Type >::CL_Vec2 ( const CL_Vec2< double > &  copy  ) 
template<typename Type>
CL_Vec2< Type >::CL_Vec2 ( const CL_Vec2< float > &  copy  ) 
template<typename Type>
CL_Vec2< Type >::CL_Vec2 ( const CL_Vec2< int > &  copy  ) 
template<>
CL_Vec2< unsigned char >::CL_Vec2 ( const CL_Vec2< float > &  copy  )  [inline]
template<>
CL_Vec2< unsigned char >::CL_Vec2 ( const CL_Vec2< double > &  copy  )  [inline]
template<>
CL_Vec2< unsigned char >::CL_Vec2 ( const CL_Vec2< int > &  copy  )  [inline]
template<>
CL_Vec2< char >::CL_Vec2 ( const CL_Vec2< float > &  copy  )  [inline]
template<>
CL_Vec2< char >::CL_Vec2 ( const CL_Vec2< double > &  copy  )  [inline]
template<>
CL_Vec2< char >::CL_Vec2 ( const CL_Vec2< int > &  copy  )  [inline]
template<>
CL_Vec2< unsigned short >::CL_Vec2 ( const CL_Vec2< float > &  copy  )  [inline]
template<>
CL_Vec2< unsigned short >::CL_Vec2 ( const CL_Vec2< double > &  copy  )  [inline]
template<>
CL_Vec2< unsigned short >::CL_Vec2 ( const CL_Vec2< int > &  copy  )  [inline]
template<>
CL_Vec2< short >::CL_Vec2 ( const CL_Vec2< float > &  copy  )  [inline]
template<>
CL_Vec2< short >::CL_Vec2 ( const CL_Vec2< double > &  copy  )  [inline]
template<>
CL_Vec2< short >::CL_Vec2 ( const CL_Vec2< int > &  copy  )  [inline]
template<>
CL_Vec2< unsigned int >::CL_Vec2 ( const CL_Vec2< float > &  copy  )  [inline]
template<>
CL_Vec2< unsigned int >::CL_Vec2 ( const CL_Vec2< double > &  copy  )  [inline]
template<>
CL_Vec2< unsigned int >::CL_Vec2 ( const CL_Vec2< int > &  copy  )  [inline]

Member Function Documentation

template<typename Type>
CL_Angle CL_Vec2< Type >::angle ( const CL_Vec2< Type > &  vector  )  const

Calculate the angle between this vector and an other vector.

Parameters:
vector = Second vector used to calculate angle.
Returns:
The angle between the two vectors (between 0 and PI)
template<typename Type>
CL_Angle CL_Vec2< Type >::angle_relative ( const CL_Vec2< Type > &  vector  )  const

Calculate the angle between this vector relative to another vector.

Parameters:
vector = Second vector used to calculate angle.
Returns:
The angle between the two vectors (between -PI and PI)
template<typename Type>
static CL_Pointx<Type> CL_Vec2< Type >::calc_origin ( CL_Origin  origin,
const CL_Sizex< Type > &  size 
) [static]

Returns the anchor point for the origin within the dimensions of the size structure.

Parameters:
origin = The origin
size = The size
Returns:
The point
template<typename Type>
Type CL_Vec2< Type >::distance ( const CL_Vec2< Type > &  vector  )  const

Calculate the distance between this vector and an other vector.

Parameters:
vector = Second vector used to calculate distance.
Returns:
The distance between the two vectors.
template<typename Type>
static Type CL_Vec2< Type >::dot ( const CL_Vec2< Type > &  vector_1,
const CL_Vec2< Type > &  vector_2 
) [inline, static]

Dot products a vector with an other vector.

Operates in the native datatype

Parameters:
vector_1 = First vector used for the dot product.
vector_2 = Second vector used for the dot product.
Returns:
The resulting dot product of the two vectors.
template<typename Type>
Type CL_Vec2< Type >::dot ( const CL_Vec2< Type > &  vector  )  const [inline]

Dot products this vector with an other vector.

Operates in the native datatype

Parameters:
vector Second vector used for the dot product.
Returns:
The resulting dot product of the two vectors.
template<typename Type>
Type CL_Vec2< Type >::length (  )  const

Returns the length (magnitude) of this vector.

Operates in the native datatype

Returns:
the length of the vector
template<typename Type>
static CL_Vec2<Type> CL_Vec2< Type >::normalize ( const CL_Vec2< Type > &  vector  )  [static]

Normalizes a vector.

Operates in the native datatype

Parameters:
vector = Vector to use
Returns:
normalized vector
template<typename Type>
CL_Vec2<Type>& CL_Vec2< Type >::normalize (  ) 

Normalizes this vector.

Operates in the native datatype

Returns:
reference to this object
template<typename Type>
CL_Vec2< Type >::operator Type * (  )  [inline]
template<typename Type>
CL_Vec2< Type >::operator Type *const (  )  const [inline]
template<typename Type>
bool CL_Vec2< Type >::operator!= ( const CL_Vec2< Type > &  vector  )  const [inline]

!= operator.

template<typename Type>
CL_Vec2<Type> CL_Vec2< Type >::operator* ( const CL_Vec2< Type > &  vector  )  const [inline]

* operator.

template<typename Type>
CL_Vec2<Type> CL_Vec2< Type >::operator* ( Type  value  )  const [inline]

* operator.

template<typename Type>
void CL_Vec2< Type >::operator*= ( Type  value  )  [inline]

*= operator.

template<typename Type>
void CL_Vec2< Type >::operator*= ( const CL_Vec2< Type > &  vector  )  [inline]

*= operator.

template<typename Type>
CL_Vec2<Type> CL_Vec2< Type >::operator+ ( const CL_Vec2< Type > &  vector  )  const [inline]

+ operator.

template<typename Type>
CL_Vec2<Type> CL_Vec2< Type >::operator+ ( Type  value  )  const [inline]

+ operator.

template<typename Type>
void CL_Vec2< Type >::operator+= ( Type  value  )  [inline]

+= operator.

template<typename Type>
void CL_Vec2< Type >::operator+= ( const CL_Vec2< Type > &  vector  )  [inline]

+= operator.

template<typename Type>
CL_Vec2<Type> CL_Vec2< Type >::operator- ( const CL_Vec2< Type > &  vector  )  const [inline]

  • operator.

template<typename Type>
CL_Vec2<Type> CL_Vec2< Type >::operator- ( Type  value  )  const [inline]

  • operator.

template<typename Type>
CL_Vec2<Type> CL_Vec2< Type >::operator- (  )  const [inline]

  • operator.

template<typename Type>
void CL_Vec2< Type >::operator-= ( const CL_Vec2< Type > &  vector  )  [inline]

-= operator.

template<typename Type>
void CL_Vec2< Type >::operator-= ( Type  value  )  [inline]

-= operator.

template<typename Type>
CL_Vec2<Type> CL_Vec2< Type >::operator/ ( Type  value  )  const [inline]

/ operator.

template<typename Type>
CL_Vec2<Type> CL_Vec2< Type >::operator/ ( const CL_Vec2< Type > &  vector  )  const [inline]

/ operator.

template<typename Type>
void CL_Vec2< Type >::operator/= ( const CL_Vec2< Type > &  vector  )  [inline]

/= operator.

template<typename Type>
void CL_Vec2< Type >::operator/= ( Type  value  )  [inline]

/= operator.

template<typename Type>
CL_Vec2<Type>& CL_Vec2< Type >::operator= ( const CL_Vec2< Type > &  vector  )  [inline]

= operator.

template<typename Type>
bool CL_Vec2< Type >::operator== ( const CL_Vec2< Type > &  vector  )  const [inline]

== operator.

template<typename Type>
Type& CL_Vec2< Type >::operator[] ( unsigned int  i  )  [inline]
template<typename Type>
const Type& CL_Vec2< Type >::operator[] ( unsigned int  i  )  const [inline]
template<typename Type>
static CL_Vec2<Type> CL_Vec2< Type >::rotate ( const CL_Vec2< Type > &  vector,
const CL_Vec2< Type > &  hotspot,
const CL_Angle angle 
) [static]

Rotate a vector around another point.

Parameters:
vector = Vector to use
hotspot The point around which to rotate.
angle = Angle to rotate.
template<typename Type>
CL_Vec2<Type>& CL_Vec2< Type >::rotate ( const CL_Vec2< Type > &  hotspot,
const CL_Angle angle 
)

Rotate this vector around another point.

Parameters:
hotspot The point around which to rotate.
angle = Angle to rotate.
Returns:
reference to this object
template<typename Type>
static CL_Vec2<Type> CL_Vec2< Type >::round ( const CL_Vec2< Type > &  vector  )  [static]

Rounds all components on a vector.

Uses Asymmetric Arithmetic Rounding

Parameters:
vector = Vector to use
Returns:
The rounded vector
template<typename Type>
CL_Vec2<Type>& CL_Vec2< Type >::round (  ) 

Rounds all components of this vector.

Uses Asymmetric Arithmetic Rounding

Returns:
reference to this object
template<typename Type>
Type CL_Vec2< Type >::round_value ( float  value  )  const

Rounds a value for the datatype.

For doubles and floats, this function does not round.

Parameters:
value = Value to round
Returns:
The rounded value

Member Data Documentation

union { ... }
union { ... }
template<typename Type>
Type CL_Vec2< Type >::g
template<typename Type>
Type CL_Vec2< Type >::r
template<typename Type>
Type CL_Vec2< Type >::s
template<typename Type>
Type CL_Vec2< Type >::t
template<typename Type>
Type CL_Vec2< Type >::x
template<typename Type>
Type CL_Vec2< Type >::y

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