2D vector More...

#include <line.h>

+ Inheritance diagram for uicore::Vec2< Type >:

Public Types

typedef Type datatype
 

Public Member Functions

 Vec2 ()
 
 Vec2 (const Type &scalar)
 
 Vec2 (const Vec3< Type > &copy)
 
 Vec2 (const Vec4< Type > &copy)
 
 Vec2 (const Type &p1, const Type &p2)
 
 Vec2 (const Type *array_xy)
 
 Vec2 (const Vec2< double > &copy)
 
 Vec2 (const Vec2< float > &copy)
 
 Vec2 (const Vec2< int > &copy)
 
template<>
 Vec2 (const Vec2< float > &copy)
 
template<>
 Vec2 (const Vec2< double > &copy)
 
template<>
 Vec2 (const Vec2< int > &copy)
 
template<>
 Vec2 (const Vec2< float > &copy)
 
template<>
 Vec2 (const Vec2< double > &copy)
 
template<>
 Vec2 (const Vec2< int > &copy)
 
template<>
 Vec2 (const Vec2< float > &copy)
 
template<>
 Vec2 (const Vec2< double > &copy)
 
template<>
 Vec2 (const Vec2< int > &copy)
 
template<>
 Vec2 (const Vec2< float > &copy)
 
template<>
 Vec2 (const Vec2< double > &copy)
 
template<>
 Vec2 (const Vec2< int > &copy)
 
template<>
 Vec2 (const Vec2< float > &copy)
 
template<>
 Vec2 (const Vec2< double > &copy)
 
template<>
 Vec2 (const Vec2< int > &copy)
 
template<>
 Vec2 (const Vec2< float > &copy)
 
template<>
 Vec2 (const Vec2< double > &copy)
 
template<>
 Vec2 (const Vec2< int > &copy)
 
template<>
 Vec2 (const Vec2< float > &copy)
 
template<>
 Vec2 (const Vec2< double > &copy)
 
template<>
 Vec2 (const Vec2< int > &copy)
 
template<>
 Vec2 (const Vec2< float > &copy)
 
template<>
 Vec2 (const Vec2< double > &copy)
 
template<>
 Vec2 (const Vec2< int > &copy)
 
Type angle (const Vec2< Type > &vector) const
 Calculate the angle between this vector and an other vector. More...
 
Type angle_line (const Vec2< Type > &point) const
 Calculate the angle of the line joining this point and other point. More...
 
Type angle_normed (const Vec2< Type > &vector) const
 Calculate the angle between this vector and an other vector, where the vectors are unit vectors. More...
 
Type distance (const Vec2< Type > &vector) const
 Calculate the distance between this vector and an other vector. More...
 
Type dot (const Vec2< Type > &vector) const
 Dot products this vector with an other vector. More...
 
bool is_equal (const Vec2< Type > &other, Type epsilon) const
 Returns true if equal within the bounds of an epsilon. More...
 
Type length () const
 Returns the length (magnitude) of this vector. More...
 
template<>
double length () const
 
template<>
float length () const
 
Vec2< Type > & normalize ()
 Normalizes this vector. More...
 
bool operator!= (const Vec2< Type > &vector) const
 != operator. More...
 
void operator*= (const Vec2< Type > &vector)
 *= operator. More...
 
void operator*= (Type value)
 *= operator. More...
 
void operator+= (const Vec2< Type > &vector)
 += operator. More...
 
void operator+= (Type value)
 += operator. More...
 
Vec2< Type > operator- () const
 
  • operator.
More...
 
void operator-= (const Vec2< Type > &vector)
 -= operator. More...
 
void operator-= (Type value)
 -= operator. More...
 
void operator/= (const Vec2< Type > &vector)
 /= operator. More...
 
void operator/= (Type value)
 /= operator. More...
 
bool operator< (const Vec2< Type > &vector) const
 < operator. More...
 
Vec2< Type > & operator= (const Vec2< Type > &vector)
 = operator. More...
 
bool operator== (const Vec2< Type > &vector) const
 == operator. More...
 
Vec2< Type > & rotate (const Vec2< Type > &hotspot, Type angle)
 Rotate this vector around another point. More...
 
Vec2< Type > & round ()
 Rounds all components of this vector. More...
 
Type round_value (float value) const
 Rounds a value for the datatype. More...
 

Static Public Member Functions

static Pointx< Type > calc_origin (Origin origin, const Sizex< Type > &size)
 Returns the anchor point for the origin within the dimensions of the size structure. More...
 
static Type dot (const Vec2< Type > &vector_1, const Vec2< Type > &vector_2)
 Dot products a vector with an other vector. More...
 
static bool is_equal (const Vec2< Type > &first, const Vec2< Type > &second, Type epsilon)
 Returns true if equal within the bounds of an epsilon. More...
 
static Vec2< Type > normalize (const Vec2< Type > &vector)
 Normalizes a vector. More...
 
static Vec2< Type > rotate (const Vec2< Type > &vector, const Vec2< Type > &hotspot, Type angle)
 Rotate a vector around another point. More...
 
static Vec2< Type > round (const Vec2< Type > &vector)
 Rounds all components on a vector. More...
 

Public Attributes

Type x
 
Type y
 

Detailed Description

template<typename Type>
class uicore::Vec2< Type >

2D vector

These vector templates are defined for:
char (Vec2c), unsigned char (Vec2uc), short (Vec2s),
unsigned short (Vec2us), int (Vec2i), unsigned int (Vec2ui), float (Vec2f), double (Vec2d)

Member Typedef Documentation

template<typename Type>
typedef Type uicore::Vec2< Type >::datatype

Constructor & Destructor Documentation

template<typename Type>
uicore::Vec2< Type >::Vec2 ( )
inline
template<typename Type>
uicore::Vec2< Type >::Vec2 ( const Type &  scalar)
inlineexplicit
template<typename Type>
uicore::Vec2< Type >::Vec2 ( const Vec3< Type > &  copy)
inlineexplicit
template<typename Type>
uicore::Vec2< Type >::Vec2 ( const Vec4< Type > &  copy)
inlineexplicit
template<typename Type>
uicore::Vec2< Type >::Vec2 ( const Type &  p1,
const Type &  p2 
)
inlineexplicit
template<typename Type>
uicore::Vec2< Type >::Vec2 ( const Type *  array_xy)
inlineexplicit
template<typename Type>
uicore::Vec2< Type >::Vec2 ( const Vec2< double > &  copy)
template<typename Type>
uicore::Vec2< Type >::Vec2 ( const Vec2< float > &  copy)
template<typename Type>
uicore::Vec2< Type >::Vec2 ( const Vec2< int > &  copy)
template<>
uicore::Vec2< unsigned char >::Vec2 ( const Vec2< float > &  copy)
inline
template<>
uicore::Vec2< unsigned char >::Vec2 ( const Vec2< double > &  copy)
inline
template<>
uicore::Vec2< unsigned char >::Vec2 ( const Vec2< int > &  copy)
inline
template<>
uicore::Vec2< char >::Vec2 ( const Vec2< float > &  copy)
inline
template<>
uicore::Vec2< char >::Vec2 ( const Vec2< double > &  copy)
inline
template<>
uicore::Vec2< char >::Vec2 ( const Vec2< int > &  copy)
inline
template<>
uicore::Vec2< unsigned short >::Vec2 ( const Vec2< float > &  copy)
inline
template<>
uicore::Vec2< unsigned short >::Vec2 ( const Vec2< double > &  copy)
inline
template<>
uicore::Vec2< unsigned short >::Vec2 ( const Vec2< int > &  copy)
inline
template<>
uicore::Vec2< short >::Vec2 ( const Vec2< float > &  copy)
inline
template<>
uicore::Vec2< short >::Vec2 ( const Vec2< double > &  copy)
inline
template<>
uicore::Vec2< short >::Vec2 ( const Vec2< int > &  copy)
inline
template<>
uicore::Vec2< int >::Vec2 ( const Vec2< float > &  copy)
inline
template<>
uicore::Vec2< int >::Vec2 ( const Vec2< double > &  copy)
inline
template<>
uicore::Vec2< int >::Vec2 ( const Vec2< int > &  copy)
inline
template<>
uicore::Vec2< unsigned int >::Vec2 ( const Vec2< float > &  copy)
inline
template<>
uicore::Vec2< unsigned int >::Vec2 ( const Vec2< double > &  copy)
inline
template<>
uicore::Vec2< unsigned int >::Vec2 ( const Vec2< int > &  copy)
inline
template<>
uicore::Vec2< float >::Vec2 ( const Vec2< float > &  copy)
inline
template<>
uicore::Vec2< float >::Vec2 ( const Vec2< double > &  copy)
inline
template<>
uicore::Vec2< float >::Vec2 ( const Vec2< int > &  copy)
inline
template<>
uicore::Vec2< double >::Vec2 ( const Vec2< float > &  copy)
inline
template<>
uicore::Vec2< double >::Vec2 ( const Vec2< double > &  copy)
inline
template<>
uicore::Vec2< double >::Vec2 ( const Vec2< int > &  copy)
inline

Member Function Documentation

template<typename Type>
Type uicore::Vec2< Type >::angle ( const 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
template<typename Type>
Type uicore::Vec2< Type >::angle_line ( const Vec2< Type > &  point) const

Calculate the angle of the line joining this point and other point.

Parameters
point= Second point in the line
Returns
The angle
template<typename Type>
Type uicore::Vec2< Type >::angle_normed ( const Vec2< Type > &  vector) const

Calculate the angle between this vector and an other vector, where the vectors are unit vectors.

Parameters
vector= Second vector used to calculate angle.
Returns
The angle between the two vectors
template<typename Type>
static Pointx<Type> uicore::Vec2< Type >::calc_origin ( Origin  origin,
const 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

Referenced by uicore::Rectx< int >::apply_alignment().

template<typename Type>
Type uicore::Vec2< Type >::distance ( const 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.

Referenced by uicore::Circlex< int >::is_inside().

template<typename Type>
static Type uicore::Vec2< Type >::dot ( const Vec2< Type > &  vector_1,
const Vec2< Type > &  vector_2 
)
inlinestatic

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 uicore::Vec2< Type >::dot ( const Vec2< Type > &  vector) const
inline

Dot products this vector with an other vector.

Operates in the native datatype

Parameters
vectorSecond vector used for the dot product.
Returns
The resulting dot product of the two vectors.
template<typename Type>
static bool uicore::Vec2< Type >::is_equal ( const Vec2< Type > &  first,
const Vec2< Type > &  second,
Type  epsilon 
)
inlinestatic

Returns true if equal within the bounds of an epsilon.

Parameters
first= Value A
second= Value B
epsilon= The epsilon (eg FLT_EPSILON/2, DBL_EPSILON/2)

Referenced by uicore::Vec2< int >::is_equal().

template<typename Type>
bool uicore::Vec2< Type >::is_equal ( const Vec2< Type > &  other,
Type  epsilon 
) const
inline

Returns true if equal within the bounds of an epsilon.

Parameters
other= Other value
epsilon= The epsilon (eg FLT_EPSILON/2, DBL_EPSILON/2)
template<typename Type >
Type uicore::Vec2< Type >::length ( ) const
inline

Returns the length (magnitude) of this vector.

Operates in the native datatype

Returns
the length of the vector

References uicore::f, uicore::x, and uicore::y.

template<>
double uicore::Vec2< double >::length ( ) const
inline

References uicore::x, and uicore::y.

template<>
float uicore::Vec2< float >::length ( ) const
inline

References uicore::x, and uicore::y.

template<typename Type>
Vec2< Type > uicore::Vec2< Type >::normalize ( const Vec2< Type > &  vector)
inlinestatic

Normalizes a vector.

Operates in the native datatype

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

Normalizes this vector.

Operates in the native datatype

Returns
reference to this object

References uicore::f, uicore::length, uicore::x, and uicore::y.

template<typename Type>
bool uicore::Vec2< Type >::operator!= ( const Vec2< Type > &  vector) const
inline

!= operator.

template<typename Type>
void uicore::Vec2< Type >::operator*= ( const Vec2< Type > &  vector)
inline

*= operator.

template<typename Type>
void uicore::Vec2< Type >::operator*= ( Type  value)
inline

*= operator.

template<typename Type>
void uicore::Vec2< Type >::operator+= ( const Vec2< Type > &  vector)
inline

+= operator.

template<typename Type>
void uicore::Vec2< Type >::operator+= ( Type  value)
inline

+= operator.

template<typename Type>
Vec2<Type> uicore::Vec2< Type >::operator- ( ) const
inline

  • operator.

template<typename Type>
void uicore::Vec2< Type >::operator-= ( const Vec2< Type > &  vector)
inline

-= operator.

template<typename Type>
void uicore::Vec2< Type >::operator-= ( Type  value)
inline

-= operator.

template<typename Type>
void uicore::Vec2< Type >::operator/= ( const Vec2< Type > &  vector)
inline

/= operator.

template<typename Type>
void uicore::Vec2< Type >::operator/= ( Type  value)
inline

/= operator.

template<typename Type>
bool uicore::Vec2< Type >::operator< ( const Vec2< Type > &  vector) const
inline

< operator.

template<typename Type>
Vec2<Type>& uicore::Vec2< Type >::operator= ( const Vec2< Type > &  vector)
inline

= operator.

template<typename Type>
bool uicore::Vec2< Type >::operator== ( const Vec2< Type > &  vector) const
inline

== operator.

template<typename Type>
static Vec2<Type> uicore::Vec2< Type >::rotate ( const Vec2< Type > &  vector,
const Vec2< Type > &  hotspot,
Type  angle 
)
static

Rotate a vector around another point.

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

Rotate this vector around another point.

Parameters
hotspotThe point around which to rotate.
angle= Angle to rotate.
Returns
reference to this object
template<typename Type>
static Vec2<Type> uicore::Vec2< Type >::round ( const 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>
Vec2<Type>& uicore::Vec2< Type >::round ( )

Rounds all components of this vector.

Uses Asymmetric Arithmetic Rounding

Returns
reference to this object
template<typename Type>
Type uicore::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


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