Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
clan::Vec2< Type > Class Template Reference
clanCore Math

2D vector More...

`#include <line.h>`

Inheritance diagram for clan::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)
template<>
double | length () const
template<>
float | length () const
Attributes
Type | length () const
| Returns the length (magnitude) of this vector. More...
Vec2< Type > & | normalize ()
| Normalizes this vector. More...
Type | dot (const Vec2< Type > &vector) const
| Dot products this vector with an other vector. More...
Angle | angle (const Vec2< Type > &vector) const
| Calculate the angle between this vector and an other vector. More...
Angle | angle_normed (const Vec2< Type > &vector) const
| Calculate the angle between this vector and an other vector, where the vectors are unit vectors. More...
Angle | angle_line (const Vec2< Type > &point) const
| Calculate the angle of the line joining this point and other point. More...
Type | distance (const Vec2< Type > &vector) const
| Calculate the distance between this vector and an other vector. More...
Vec2< Type > & | round ()
| Rounds all components of this vector. More...
Vec2< Type > & | rotate (const Vec2< Type > &hotspot, const Angle &angle)
| Rotate this vector around another point. More...
Type | round_value (float value) const
| Rounds a value for the datatype. More...
bool | is_equal (const Vec2< Type > &other, Type epsilon) const
| Returns true if equal within the bounds of an epsilon. More...
Operators
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...
Vec2< Type > & | operator= (const Vec2< Type > &vector)
| = operator. More...
bool | operator== (const Vec2< Type > &vector) const
| == operator. More...
bool | operator!= (const Vec2< Type > &vector) const
| != operator. More...
bool | operator< (const Vec2< Type > &vector) const
| < operator. 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, const Angle &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
union {
Type clan::Vec2< Type >::r
Type clan::Vec2< Type >::s
Type clan::Vec2< Type >::x
}; |
union {
Type clan::Vec2< Type >::g
Type clan::Vec2< Type >::t
Type clan::Vec2< Type >::y
}; |

## Detailed Description

### template<typename Type>
class clan::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)

## Constructor & Destructor Documentation

template<>

clan::Vec2< unsigned char >::Vec2 | ( | const Vec2< float > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< unsigned char >::Vec2 | ( | const Vec2< double > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< unsigned char >::Vec2 | ( | const Vec2< int > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< char >::Vec2 | ( | const Vec2< float > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< char >::Vec2 | ( | const Vec2< double > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< char >::Vec2 | ( | const Vec2< int > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< unsigned short >::Vec2 | ( | const Vec2< float > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< unsigned short >::Vec2 | ( | const Vec2< double > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< unsigned short >::Vec2 | ( | const Vec2< int > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< short >::Vec2 | ( | const Vec2< float > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< short >::Vec2 | ( | const Vec2< double > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< short >::Vec2 | ( | const Vec2< int > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< int >::Vec2 | ( | const Vec2< float > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< int >::Vec2 | ( | const Vec2< double > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< int >::Vec2 | ( | const Vec2< int > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< unsigned int >::Vec2 | ( | const Vec2< float > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< unsigned int >::Vec2 | ( | const Vec2< double > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< unsigned int >::Vec2 | ( | const Vec2< int > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< float >::Vec2 | ( | const Vec2< float > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< float >::Vec2 | ( | const Vec2< double > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< float >::Vec2 | ( | const Vec2< int > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< double >::Vec2 | ( | const Vec2< float > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< double >::Vec2 | ( | const Vec2< double > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

template<>

clan::Vec2< double >::Vec2 | ( | const Vec2< int > & | copy | ) |
| inline

References clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.

## Member Function Documentation

template<>

double clan::Vec2< double >::length | ( |  | ) | const
| inline

References clan::x, and clan::y.

template<>

float clan::Vec2< float >::length | ( |  | ) | const
| inline

References clan::x, and clan::y.

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

- line.h
- vec2.h