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 );
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>
307 template<
typename Type>
311 template<
typename Type>
315 template<
typename Type>
319 template<
typename Type>
322 template<
typename Type>
326 matrix[0*2+0]*
v.x + matrix[0*2+1]*
v.y,
327 matrix[1*2+0]*
v.x + matrix[1*2+1]*
v.y);
330 template<
typename Type>
334 matrix[0*2+0]*
v.x + matrix[1*2+0]*
v.y,
335 matrix[0*2+1]*
v.x + matrix[1*2+1]*
v.y);
412 template<
typename Type>
421 template<
typename Type>
424 template<
typename Type>
Type x
Definition: vec4.h:80
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.
Vec2< Type > operator-() const
operator.
Definition: vec2.h:246
void operator/=(const Vec2< Type > &vector)
/= operator.
Definition: vec2.h:255
Vec2< Type > & rotate(const Vec2< Type > &hotspot, const Angle &angle)
Rotate this vector around another point.
Vec2< short > Vec2s
Definition: vec2.h:432
static Vec2< Type > normalize(const Vec2< Type > &vector)
Normalizes a vector.
Definition: vec2.h:425
Type y
Definition: vec2.h:81
void operator*=(const Vec2< Type > &vector)
*= operator.
Definition: vec2.h:249
void operator-=(const Vec2< Type > &vector)
-= operator.
Definition: vec2.h:240
2D (x,y) point structure.
Definition: point.h:53
Type datatype
Definition: vec2.h:78
Type distance(const Vec2< Type > &vector) const
Calculate the distance between this vector and an other vector.
Vec2< Type > operator+(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:276
Type t
Definition: vec2.h:81
Vec2(const Vec2< double > ©)
bool operator<(const Vec2< Type > &vector) const
< operator.
Definition: vec2.h:270
Vec2< unsigned short > Vec2us
Definition: vec2.h:431
Vec2(const Type &p1, const Type &p2)
Definition: vec2.h:87
Origin
Alignment origins.
Definition: origin.h:41
Vec2(const Vec2< float > ©)
Vec2(const Vec3< Type > ©)
Definition: vec2.h:85
Type x
Definition: vec2.h:80
Vec2()
Definition: vec2.h:83
Vec2< double > Vec2d
Definition: vec2.h:436
2D matrix
Definition: mat2.h:45
Vec2< Type > operator/(const Vec2< Type > &v1, const Vec2< Type > &v2)
/ operator.
Definition: vec2.h:312
bool operator!=(const Vec2< Type > &vector) const
!= operator.
Definition: vec2.h:267
Angle class.
Definition: angle.h:63
Vec2< Type > operator*(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:300
static Vec2< Type > round(const Vec2< Type > &vector)
Rounds all components on a vector.
Type g
Definition: vec2.h:81
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.
@ length
value is a keyword
Vec2(const Vec4< Type > ©)
Definition: vec2.h:86
Vec2< char > Vec2b
Definition: vec2.h:430
Angle angle(const Vec2< Type > &vector) const
Calculate the angle between this vector and an other vector.
4D vector
Definition: size.h:47
Type dot(const Vec2< Type > &vector) const
Dot products this vector with an other vector.
Definition: vec2.h:170
Type s
Definition: vec2.h:80
Vec2< float > Vec2f
Definition: vec2.h:435
Vec2(const Type *array_xy)
Definition: vec2.h:88
Vec2(const Vec2< int > ©)
Type y
Definition: vec4.h:81
Vec2< Type > operator-(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:288
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 r
Definition: vec2.h:80
Vec2< Type > & operator=(const Vec2< Type > &vector)
= operator.
Definition: vec2.h:261
Type round_value(float value) const
Rounds a value for the datatype.
bool is_equal(const Vec2< Type > &other, Type epsilon) const
Returns true if equal within the bounds of an epsilon.
Definition: vec2.h:226
3D vector
Definition: line_ray.h:48
Vec2(const Type &scalar)
Definition: vec2.h:84
Type x
Definition: vec3.h:80
Vec2< Type > & normalize()
Normalizes this vector.
Definition: vec2.h:422
Vec2< unsigned char > Vec2ub
Definition: vec2.h:429
Vec2< int > Vec2i
Definition: vec2.h:434
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
2D (width,height) size structure.
Definition: size.h:55
static Vec2< Type > rotate(const Vec2< Type > &vector, const Vec2< Type > &hotspot, const Angle &angle)
Rotate a vector around another point.
Type length() const
Returns the length (magnitude) of this vector.
Definition: vec2.h:413
Vec2< Type > & round()
Rounds all components of this vector.
Vec2< unsigned int > Vec2ui
Definition: vec2.h:433
bool operator==(const Vec2< Type > &vector) const
== operator.
Definition: vec2.h:264
void operator+=(const Vec2< Type > &vector)
+= operator.
Definition: vec2.h:234
Type y
Definition: vec3.h:81