40 template<
typename Type>
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>
69 template<
typename Type>
79 explicit Vec2(
const Type &scalar) : x(scalar), y(scalar) { }
82 explicit Vec2(
const Type &p1,
const Type &p2) : x(p1), y(p2) { }
83 explicit Vec2(
const Type *array_xy) : x(array_xy[0]), y(array_xy[1]) { }
104 static Type
dot(
const Vec2<Type>& vector_1,
const Vec2<Type>& vector_2) {
return vector_1.x*vector_2.x + vector_1.y*vector_2.y; }
135 Type diff_x = second.x - first.x; Type diff_y = second.y - first.y;
136 return (diff_x >= -epsilon && diff_x <= epsilon && diff_y >= -epsilon && diff_y <= epsilon);
160 Type
dot(
const Vec2<Type>& vector)
const {
return x*vector.x + y*vector.y; }
255 bool operator < (const Vec2<Type>& vector)
const {
return y < vector.y || (y == vector.y && x < vector.x); }
259 template<
typename Type>
263 template<
typename Type>
267 template<
typename Type>
271 template<
typename Type>
275 template<
typename Type>
279 template<
typename Type>
283 template<
typename Type>
287 template<
typename Type>
291 template<
typename Type>
295 template<
typename Type>
299 template<
typename Type>
303 template<
typename Type>
306 template<
typename Type>
310 matrix[0 * 2 + 0] * v.x + matrix[0 * 2 + 1] * v.y,
311 matrix[1 * 2 + 0] * v.x + matrix[1 * 2 + 1] * v.y);
314 template<
typename Type>
318 matrix[0 * 2 + 0] * v.x + matrix[1 * 2 + 0] * v.y,
319 matrix[0 * 2 + 1] * v.x + matrix[1 * 2 + 1] * v.y);
396 template<
typename Type>
405 template<
typename Type>
408 template<
typename Type>
Type round_value(float value) const
Rounds a value for the datatype.
Type datatype
Definition: vec2.h:73
void operator/=(const Vec2< Type > &vector)
/= operator.
Definition: vec2.h:240
static Type dot(const Vec2< Type > &vector_1, const Vec2< Type > &vector_2)
Dot products a vector with an other vector.
Definition: vec2.h:104
Vec2()
Definition: vec2.h:78
2D matrix
Definition: mat2.h:41
Type x
Definition: vec3.h:74
2D (width,height) size structure.
Definition: size.h:51
Type distance(const Vec2< Type > &vector) const
Calculate the distance between this vector and an other vector.
Vec2(const Type *array_xy)
Definition: vec2.h:83
3D vector
Definition: line_ray.h:43
Type x
Definition: vec4.h:74
void operator+=(const Vec2< Type > &vector)
+= operator.
Definition: vec2.h:219
Type x
Definition: vec2.h:75
void operator-=(const Vec2< Type > &vector)
-= operator.
Definition: vec2.h:225
2D (x,y) point structure.
Definition: point.h:48
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 angle_line(const Vec2< Type > &point) const
Calculate the angle of the line joining this point and other point.
Vec2< Type > operator-(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:272
Vec2(const Type &p1, const Type &p2)
Definition: vec2.h:82
bool is_equal(const Vec2< Type > &other, Type epsilon) const
Returns true if equal within the bounds of an epsilon.
Definition: vec2.h:216
Vec2< Type > operator+(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:260
Vec2< Type > & normalize()
Normalizes this vector.
Definition: vec2.h:406
Type angle_normed(const Vec2< Type > &vector) const
Calculate the angle between this vector and an other vector, where the vectors are unit vectors...
Type y
Definition: vec2.h:76
Type length() const
Returns the length (magnitude) of this vector.
Definition: vec2.h:397
Type y
Definition: vec4.h:75
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:133
bool operator==(const Vec2< Type > &vector) const
== operator.
Definition: vec2.h:249
Vec2< Type > operator/(const Vec2< Type > &v1, const Vec2< Type > &v2)
/ operator.
Definition: vec2.h:296
bool operator!=(const Vec2< Type > &vector) const
!= operator.
Definition: vec2.h:252
Type angle(const Vec2< Type > &vector) const
Calculate the angle between this vector and an other vector.
Vec2< Type > & operator=(const Vec2< Type > &vector)
= operator.
Definition: vec2.h:246
Vec2< Type > operator-() const
operator.
Definition: vec2.h:231
Vec2(const Vec3< Type > ©)
Definition: vec2.h:80
void operator*=(const Vec2< Type > &vector)
*= operator.
Definition: vec2.h:234
Vec2< Type > & round()
Rounds all components of this vector.
Vec2< Type > operator*(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:284
Type y
Definition: vec3.h:75
Type dot(const Vec2< Type > &vector) const
Dot products this vector with an other vector.
Definition: vec2.h:160
Vec2(const Vec4< Type > ©)
Definition: vec2.h:81
Vec2(const Type &scalar)
Definition: vec2.h:79
Origin
Alignment origins.
Definition: origin.h:35
Definition: Application/application.h:35
4D vector
Definition: size.h:44
static Vec2< Type > rotate(const Vec2< Type > &vector, const Vec2< Type > &hotspot, Type angle)
Rotate a vector around another point.