2D vector More...
#include <vec2.h>
Public Types | |
typedef Type | datatype |
Public Member Functions | |
Vec2 () | |
Vec2 (const Type &p1, const Type &p2) | |
Vec2 (const Type &scalar) | |
Vec2 (const Type *array_xy) | |
template<typename OtherType, typename std::enable_if_t< std::is_integral< Type >::value &&!std::is_integral< OtherType >::value, int > = 0> | |
Vec2 (const Vec2< OtherType > ©) | |
template<typename OtherType, typename std::enable_if_t<!std::is_integral< Type >::value||std::is_integral< OtherType >::value, int > = 0> | |
Vec2 (const Vec2< OtherType > ©) | |
Vec2 (const Vec2< Type > ©)=default | |
Vec2 (const Vec3< Type > ©) | |
Vec2 (const Vec4< Type > ©) | |
Angle | angle (const Vec2< Type > &vector) const |
Calculate the angle between this vector and an other vector. | |
Angle | angle_line (const Vec2< Type > &point) const |
Calculate the angle of the line joining this point and other point. | |
Angle | angle_normed (const Vec2< Type > &vector) const |
Calculate the angle between this vector and an other vector, where the vectors are unit vectors. | |
Type | distance (const Vec2< Type > &vector) const |
Calculate the distance between this vector and an other vector. | |
Type | dot (const Vec2< Type > &vector) const |
Dot products this vector with an other vector. | |
bool | is_equal (const Vec2< Type > &other, Type epsilon) const |
Returns true if equal within the bounds of an epsilon. | |
Type | length () const |
Returns the length (magnitude) of this vector. | |
double | length () const |
float | length () const |
Vec2< Type > & | normalize () |
Normalizes this vector. | |
bool | operator!= (const Vec2< Type > &vector) const |
!= operator. | |
void | operator*= (const Vec2< Type > &vector) |
*= operator. | |
void | operator*= (Type value) |
*= operator. | |
void | operator+= (const Vec2< Type > &vector) |
+= operator. | |
void | operator+= (Type value) |
+= operator. | |
Vec2< Type > | operator- () const |
| |
void | operator-= (const Vec2< Type > &vector) |
-= operator. | |
void | operator-= (Type value) |
-= operator. | |
void | operator/= (const Vec2< Type > &vector) |
/= operator. | |
void | operator/= (Type value) |
/= operator. | |
bool | operator< (const Vec2< Type > &vector) const |
< operator. | |
Vec2< Type > & | operator= (const Vec2< Type > &vector)=default |
= operator. | |
bool | operator== (const Vec2< Type > &vector) const |
== operator. | |
Vec2< Type > & | rotate (const Vec2< Type > &hotspot, const Angle &angle) |
Rotate this vector around another point. | |
Vec2< Type > & | round () |
Rounds all components of this vector. | |
Type | round_value (float value) const |
Rounds a value for the datatype. | |
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. | |
static Type | dot (const Vec2< Type > &vector_1, const Vec2< Type > &vector_2) |
Dot products a vector with an other vector. | |
static bool | is_equal (const Vec2< Type > &first, const Vec2< Type > &second, Type epsilon) |
Returns true if equal within the bounds of an epsilon. | |
static Vec2< Type > | normalize (const Vec2< Type > &vector) |
Normalizes a vector. | |
static Vec2< Type > | rotate (const Vec2< Type > &vector, const Vec2< Type > &hotspot, const Angle &angle) |
Rotate a vector around another point. | |
static Vec2< Type > | round (const 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 | ||
}; | ||
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)
typedef Type clan::Vec2< Type >::datatype |
|
inline |
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
|
default |
|
inline |
|
inline |
Angle clan::Vec2< Type >::angle | ( | const Vec2< Type > & | vector | ) | const |
Calculate the angle between this vector and an other vector.
vector | = Second vector used to calculate angle. |
Angle clan::Vec2< Type >::angle_line | ( | const Vec2< Type > & | point | ) | const |
Calculate the angle of the line joining this point and other point.
point | = Second point in the line |
Angle clan::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.
vector | = Second vector used to calculate angle. |
|
static |
Returns the anchor point for the origin within the dimensions of the size structure.
origin | = The origin |
size | = The size |
Referenced by clan::Rectx< Type >::apply_alignment().
Type clan::Vec2< Type >::distance | ( | const Vec2< Type > & | vector | ) | const |
Calculate the distance between this vector and an other vector.
vector | = Second vector used to calculate distance. |
|
inline |
Dot products this vector with an other vector.
Operates in the native datatype
vector | Second vector used for the dot product. |
|
inlinestatic |
Dot products a vector with an other vector.
Operates in the native datatype
vector_1 | = First vector used for the dot product. |
vector_2 | = Second vector used for the dot product. |
|
inlinestatic |
Returns true if equal within the bounds of an epsilon.
first | = Value A |
second | = Value B |
epsilon | = The epsilon (eg FLT_EPSILON/2, DBL_EPSILON/2) |
Referenced by clan::Vec2< unsigned char >::is_equal().
|
inline |
Returns true if equal within the bounds of an epsilon.
other | = Other value |
epsilon | = The epsilon (eg FLT_EPSILON/2, DBL_EPSILON/2) |
|
inline |
|
inline |
|
inline |
!= operator.
|
inline |
*= operator.
|
inline |
*= operator.
|
inline |
+= operator.
|
inline |
+= operator.
|
inline |
|
inline |
-= operator.
|
inline |
-= operator.
|
inline |
/= operator.
|
inline |
/= operator.
|
inline |
< operator.
|
default |
= operator.
|
inline |
== operator.
Vec2< Type > & clan::Vec2< Type >::rotate | ( | const Vec2< Type > & | hotspot, |
const Angle & | angle ) |
Rotate this vector around another point.
hotspot | The point around which to rotate. |
angle | = Angle to rotate. |
|
static |
Rotate a vector around another point.
vector | = Vector to use |
hotspot | The point around which to rotate. |
angle | = Angle to rotate. |
Vec2< Type > & clan::Vec2< Type >::round | ( | ) |
Rounds all components of this vector.
Uses Asymmetric Arithmetic Rounding
|
static |
Rounds all components on a vector.
Uses Asymmetric Arithmetic Rounding
vector | = Vector to use |
Type clan::Vec2< Type >::round_value | ( | float | value | ) | const |
Rounds a value for the datatype.
For doubles and floats, this function does not round.
value | = Value to round |
union { ... } clan::Vec2< Type > |
union { ... } clan::Vec2< Type > |
Type clan::Vec2< Type >::g |
Type clan::Vec2< Type >::r |
Type clan::Vec2< Type >::s |
Type clan::Vec2< Type >::t |
Type clan::Vec2< Type >::x |
Referenced by clan::Pointx< Type >::Pointx(), clan::Pointx< Type >::Pointx(), clan::Pointx< Type >::Pointx(), clan::Rectx< Type >::apply_alignment(), clan::Vec2< unsigned char >::dot(), clan::Vec2< unsigned char >::dot(), clan::Vec2< unsigned char >::is_equal(), length(), normalize(), clan::Vec2< unsigned char >::operator!=(), clan::operator*(), clan::Vec2< unsigned char >::operator*=(), clan::operator+(), clan::Vec2< unsigned char >::operator+=(), clan::operator-(), clan::Vec2< unsigned char >::operator-=(), clan::operator/(), clan::Vec2< unsigned char >::operator/=(), clan::Vec2< unsigned char >::operator<(), clan::operator<<(), clan::Vec2< unsigned char >::operator==(), clan::ProgramObject::set_uniform2b(), clan::ProgramObject::set_uniform2f(), clan::ProgramObject::set_uniform2i(), clan::ProgramObject::set_uniform2s(), clan::ProgramObject::set_uniformfv(), clan::ProgramObject::set_uniformiv(), clan::Vec4< unsigned char >::set_xy(), clan::Vec4< unsigned char >::set_zw(), clan::step(), and clan::Mat3< int >::translate().
Type clan::Vec2< Type >::y |
Referenced by clan::Pointx< Type >::Pointx(), clan::Pointx< Type >::Pointx(), clan::Pointx< Type >::Pointx(), clan::Rectx< Type >::apply_alignment(), clan::Vec2< unsigned char >::dot(), clan::Vec2< unsigned char >::dot(), clan::Vec2< unsigned char >::is_equal(), length(), normalize(), clan::Vec2< unsigned char >::operator!=(), clan::operator*(), clan::Vec2< unsigned char >::operator*=(), clan::operator+(), clan::Vec2< unsigned char >::operator+=(), clan::operator-(), clan::Vec2< unsigned char >::operator-=(), clan::operator/(), clan::Vec2< unsigned char >::operator/=(), clan::Vec2< unsigned char >::operator<(), clan::operator<<(), clan::Vec2< unsigned char >::operator==(), clan::ProgramObject::set_uniform2b(), clan::ProgramObject::set_uniform2f(), clan::ProgramObject::set_uniform2i(), clan::ProgramObject::set_uniform2s(), clan::Vec4< unsigned char >::set_xy(), clan::Vec4< unsigned char >::set_zw(), clan::step(), and clan::Mat3< int >::translate().