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]) { }
109 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; }
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);
260 bool operator < (const Vec2<Type>& vector)
const {
return y < vector.y || (
y == vector.y &&
x < vector.x); }
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>
Vec2< float > Vec2f
Definition: vec2.h:425
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 Vec3< Type > ©)
Definition: vec2.h:85
Angle class.
Definition: angle.h:59
Vec2< Type > & operator=(const Vec2< Type > &vector)
= operator.
Definition: vec2.h:251
Type length() const
Returns the length (magnitude) of this vector.
Definition: vec2.h:403
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
Vec2< Type > & round()
Rounds all components of this vector.
bool operator!=(const Vec2< Type > &vector) const
!= operator.
Definition: vec2.h:257
Vec2< unsigned char > Vec2ub
Definition: vec2.h:419
Vec2< Type > operator-() const
operator.
Definition: vec2.h:236
Origin
Alignment origins.
Definition: origin.h:38
Type x
Definition: vec3.h:79
Vec2< short > Vec2s
Definition: vec2.h:422
Vec2< unsigned short > Vec2us
Definition: vec2.h:421
Vec2< Type > operator/(const Vec2< Type > &v1, const Vec2< Type > &v2)
/ operator.
Definition: vec2.h:302
Type y
Definition: vec3.h:80
Vec2< int > Vec2i
Definition: vec2.h:424
Vec2(const Vec4< Type > ©)
Definition: vec2.h:86
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 x
Definition: vec4.h:79
void operator+=(const Vec2< Type > &vector)
+= operator.
Definition: vec2.h:224
Vec2< char > Vec2b
Definition: vec2.h:420
bool is_equal(const Vec2< Type > &other, Type epsilon) const
Returns true if equal within the bounds of an epsilon.
Definition: vec2.h:221
Vec2(const Type *array_xy)
Definition: vec2.h:88
Type s
Definition: vec2.h:80
Vec2< double > Vec2d
Definition: vec2.h:426
Type round_value(float value) const
Rounds a value for the datatype.
Vec2(const Type &p1, const Type &p2)
Definition: vec2.h:87
Type t
Definition: vec2.h:81
Vec2< Type > operator+(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:266
void operator*=(const Vec2< Type > &vector)
*= operator.
Definition: vec2.h:239
2D matrix
Definition: mat2.h:44
Type r
Definition: vec2.h:80
void operator-=(const Vec2< Type > &vector)
-= operator.
Definition: vec2.h:230
Vec2(const Type &scalar)
Definition: vec2.h:84
Angle angle(const Vec2< Type > &vector) const
Calculate the angle between this vector and an other vector.
static Vec2< Type > rotate(const Vec2< Type > &vector, const Vec2< Type > &hotspot, const Angle &angle)
Rotate a vector around another point.
Type y
Definition: vec2.h:81
Vec2< Type > operator*(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:290
3D vector
Definition: line_ray.h:46
Type datatype
Definition: vec2.h:78
Type x
Definition: vec2.h:80
Angle angle_line(const Vec2< Type > &point) const
Calculate the angle of the line joining this point and other point.
void operator/=(const Vec2< Type > &vector)
/= operator.
Definition: vec2.h:245
bool operator==(const Vec2< Type > &vector) const
== operator.
Definition: vec2.h:254
Type distance(const Vec2< Type > &vector) const
Calculate the distance between this vector and an other vector.
Type y
Definition: vec4.h:80
2D (x,y) point structure.
Definition: point.h:51
4D vector
Definition: size.h:47
Vec2< Type > operator-(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:278
Vec2()
Definition: vec2.h:83
Type dot(const Vec2< Type > &vector) const
Dot products this vector with an other vector.
Definition: vec2.h:165
Vec2< unsigned int > Vec2ui
Definition: vec2.h:423
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
Vec2< Type > & normalize()
Normalizes this vector.
Definition: vec2.h:412
2D (width,height) size structure.
Definition: size.h:54