43 template<
typename Type>
46 template<
typename Type>
49 template<
typename Type>
52 template<
typename Type>
55 template<
typename Type>
58 template<
typename Type>
61 template<
typename Type>
64 template<
typename Type>
74 template<
typename Type>
80 union { Type
x; Type
s; Type
r; };
81 union { Type
y; Type
t; Type
g; };
84 explicit Vec2(
const Type &scalar) :
x(scalar),
y(scalar) { }
87 explicit Vec2(
const Type &p1,
const Type &p2) :
x(p1),
y(p2) { }
88 explicit Vec2(
const Type *array_xy) :
x(array_xy[0]),
y(array_xy[1]) { }
140 Type diff_x = second.
x - first.
x; Type diff_y = second.
y - first.
y;
141 return (diff_x >= -epsilon && diff_x <= epsilon && diff_y >= -epsilon && diff_y <= epsilon);
265 template<
typename Type>
269 template<
typename Type>
273 template<
typename Type>
277 template<
typename Type>
281 template<
typename Type>
285 template<
typename Type>
289 template<
typename Type>
293 template<
typename Type>
297 template<
typename Type>
301 template<
typename Type>
305 template<
typename Type>
309 template<
typename Type>
312 template<
typename Type>
316 matrix[0 * 2 + 0] *
v.x + matrix[0 * 2 + 1] *
v.y,
317 matrix[1 * 2 + 0] *
v.x + matrix[1 * 2 + 1] *
v.y);
320 template<
typename Type>
324 matrix[0 * 2 + 0] *
v.x + matrix[1 * 2 + 0] *
v.y,
325 matrix[0 * 2 + 1] *
v.x + matrix[1 * 2 + 1] *
v.y);
402 template<
typename Type>
411 template<
typename Type>
414 template<
typename Type>
Angle class.
Definition: angle.h:60
2D matrix
Definition: mat2.h:59
2D (x,y) point structure.
Definition: point.h:52
2D (width,height) size structure.
Definition: size.h:55
2D vector
Definition: vec2.h:76
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.
Type g
Definition: vec2.h:81
Vec2(const Vec2< double > ©)
Type y
Definition: vec2.h:81
Angle angle_normed(const Vec2< Type > &vector) const
Calculate the angle between this vector and an other vector, where the vectors are unit vectors.
bool operator!=(const Vec2< Type > &vector) const
!= operator.
Definition: vec2.h:257
static Vec2< Type > round(const Vec2< Type > &vector)
Rounds all components on a vector.
Vec2< Type > operator-() const
operator.
Definition: vec2.h:236
void operator/=(const Vec2< Type > &vector)
/= operator.
Definition: vec2.h:245
static Type dot(const Vec2< Type > &vector_1, const Vec2< Type > &vector_2)
Dot products a vector with an other vector.
Definition: vec2.h:109
Type round_value(float value) const
Rounds a value for the datatype.
Vec2(const Type &scalar)
Definition: vec2.h:84
Vec2(const Type &p1, const Type &p2)
Definition: vec2.h:87
Vec2(const Vec3< Type > ©)
Definition: vec2.h:85
Vec2()
Definition: vec2.h:83
Type t
Definition: vec2.h:81
bool operator==(const Vec2< Type > &vector) const
== operator.
Definition: vec2.h:254
bool is_equal(const Vec2< Type > &other, Type epsilon) const
Returns true if equal within the bounds of an epsilon.
Definition: vec2.h:221
Type distance(const Vec2< Type > &vector) const
Calculate the distance between this vector and an other vector.
Vec2< Type > & operator=(const Vec2< Type > &vector)
= operator.
Definition: vec2.h:251
bool operator<(const Vec2< Type > &vector) const
< operator.
Definition: vec2.h:260
void operator+=(const Vec2< Type > &vector)
+= operator.
Definition: vec2.h:224
void operator*=(const Vec2< Type > &vector)
*= operator.
Definition: vec2.h:239
static bool is_equal(const Vec2< Type > &first, const Vec2< Type > &second, Type epsilon)
Returns true if equal within the bounds of an epsilon.
Definition: vec2.h:138
Type s
Definition: vec2.h:80
Type dot(const Vec2< Type > &vector) const
Dot products this vector with an other vector.
Definition: vec2.h:165
static Vec2< Type > rotate(const Vec2< Type > &vector, const Vec2< Type > &hotspot, const Angle &angle)
Rotate a vector around another point.
Vec2(const Vec2< float > ©)
Angle angle(const Vec2< Type > &vector) const
Calculate the angle between this vector and an other vector.
Vec2(const Type *array_xy)
Definition: vec2.h:88
Type datatype
Definition: vec2.h:78
Vec2< Type > & rotate(const Vec2< Type > &hotspot, const Angle &angle)
Rotate this vector around another point.
Type x
Definition: vec2.h:80
Type r
Definition: vec2.h:80
Angle angle_line(const Vec2< Type > &point) const
Calculate the angle of the line joining this point and other point.
Vec2(const Vec4< Type > ©)
Definition: vec2.h:86
Vec2< Type > & round()
Rounds all components of this vector.
Vec2(const Vec2< int > ©)
void operator-=(const Vec2< Type > &vector)
-= operator.
Definition: vec2.h:230
3D vector
Definition: vec3.h:75
Type y
Definition: vec3.h:80
Type x
Definition: vec3.h:79
4D vector
Definition: vec4.h:75
Type y
Definition: vec4.h:80
Type x
Definition: vec4.h:79
Vec2< Type > operator/(const Vec2< Type > &v1, const Vec2< Type > &v2)
/ operator.
Definition: vec2.h:302
Vec2< Type > & normalize()
Normalizes this vector.
Definition: vec2.h:412
Vec2< unsigned int > Vec2ui
Definition: vec2.h:423
Vec2< unsigned short > Vec2us
Definition: vec2.h:421
Vec2< double > Vec2d
Definition: vec2.h:426
Type length() const
Returns the length (magnitude) of this vector.
Definition: vec2.h:403
Vec2< char > Vec2b
Definition: vec2.h:420
Vec2< Type > operator-(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:278
static Vec2< Type > normalize(const Vec2< Type > &vector)
Normalizes a vector.
Definition: vec2.h:415
Vec2< Type > operator+(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:266
Vec2< int > Vec2i
Definition: vec2.h:424
Origin
Alignment origins.
Definition: origin.h:39
Vec2< float > Vec2f
Definition: vec2.h:425
Vec2< unsigned char > Vec2ub
Definition: vec2.h:419
Vec2< Type > operator*(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:290
Vec2< short > Vec2s
Definition: vec2.h:422
@ length
value is a keyword