39 template<
typename Type>
42 template<
typename Type>
45 template<
typename Type>
48 template<
typename Type>
51 template<
typename Type>
54 template<
typename Type>
57 template<
typename Type>
60 template<
typename Type>
68 template<
typename Type>
79 Vec4() : x(0), y(0), z(0), w(0) { }
80 explicit Vec4(
const Type &scalar) : x(scalar), y(scalar), z(scalar), w(scalar) { }
81 explicit Vec4(
const Vec2<Type> ©,
const Type &p3,
const Type &p4) { x = copy.
x; y = copy.
y; z = p3; w = p4; }
83 explicit Vec4(
const Vec3<Type> ©,
const Type &p4) { x = copy.
x; y = copy.
y; z = copy.
z; w = p4; }
84 explicit Vec4(
const Type &p1,
const Type &p2,
const Type &p3,
const Type &p4) : x(p1), y(p2), z(p3), w(p4) { }
85 explicit Vec4(
const Type &p1,
const Type &p2,
const Vec2<Type> ©34) : x(p1), y(p2), z(copy34.x), w(copy34.y) { }
86 explicit Vec4(
const Type *array_xyzw) : x(array_xyzw[0]), y(array_xyzw[1]), z(array_xyzw[2]), w(array_xyzw[3]) { }
109 static Type
dot3(
const Vec4<Type>& vector1,
const Vec4<Type>& vector2) {
return vector1.x*vector2.x + vector1.y*vector2.y + vector1.z*vector2.z; }
118 static Type
dot4(
const Vec4<Type>& vector1,
const Vec4<Type>& vector2) {
return vector1.x*vector2.x + vector1.y*vector2.y + vector1.z*vector2.z + vector1.w*vector2.w; }
153 Type diff_x = second.x - first.x; Type diff_y = second.y - first.y; Type diff_z = second.z - first.z; Type diff_w = second.w - first.w;
154 return (diff_x >= -epsilon && diff_x <= epsilon && diff_y >= -epsilon && diff_y <= epsilon && diff_z >= -epsilon && diff_z <= epsilon && diff_w >= -epsilon && diff_w <= epsilon);
192 Type
dot3(
const Vec4<Type>& vector)
const {
return x*vector.x + y*vector.y + z*vector.z; }
200 Type
dot4(
const Vec4<Type>& vector)
const {
return x*vector.x + y*vector.y + z*vector.z + w*vector.w; }
258 void operator += (Type value) { x += value; y += value; z += value; w += value; }
264 void operator -= (Type value) { x -= value; y -= value; z -= value; w -= value; }
273 void operator *= (Type value) { x *= value; y *= value; z *= value; w *= value; }
279 void operator /= (Type value) { x /= value; y /= value; z /= value; w /= value; }
285 bool operator == (
const Vec4<Type>& vector)
const {
return ((x == vector.x) && (y == vector.y) && (z == vector.z) && (w == vector.w)); }
288 bool operator != (
const Vec4<Type>& vector)
const {
return ((x != vector.x) || (y != vector.y) || (z != vector.z) || (w != vector.w)); }
291 bool operator < (const Vec4<Type>& vector)
const {
return w < vector.w || (w == vector.w && (z < vector.z || (z == vector.z && (y < vector.y || (y == vector.y && x < vector.x))))); }
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>
323 template<
typename Type>
327 template<
typename Type>
331 template<
typename Type>
335 template<
typename Type>
339 template<
typename Type>
342 template<
typename Type>
346 matrix[0 * 4 + 0] * v.x + matrix[0 * 4 + 1] * v.y + matrix[0 * 4 + 2] * v.z + matrix[0 * 4 + 3] * v.w,
347 matrix[1 * 4 + 0] * v.x + matrix[1 * 4 + 1] * v.y + matrix[1 * 4 + 2] * v.z + matrix[1 * 4 + 3] * v.w,
348 matrix[2 * 4 + 0] * v.x + matrix[2 * 4 + 1] * v.y + matrix[2 * 4 + 2] * v.z + matrix[2 * 4 + 3] * v.w,
349 matrix[3 * 4 + 0] * v.x + matrix[3 * 4 + 1] * v.y + matrix[3 * 4 + 2] * v.z + matrix[3 * 4 + 3] * v.w);
352 template<
typename Type>
356 matrix[0 * 4 + 0] * v.x + matrix[1 * 4 + 0] * v.y + matrix[2 * 4 + 0] * v.z + matrix[3 * 4 + 0] * v.w,
357 matrix[0 * 4 + 1] * v.x + matrix[1 * 4 + 1] * v.y + matrix[2 * 4 + 1] * v.z + matrix[3 * 4 + 1] * v.w,
358 matrix[0 * 4 + 2] * v.x + matrix[1 * 4 + 2] * v.y + matrix[2 * 4 + 2] * v.z + matrix[3 * 4 + 2] * v.w,
359 matrix[0 * 4 + 3] * v.x + matrix[1 * 4 + 3] * v.y + matrix[2 * 4 + 3] * v.z + matrix[3 * 4 + 3] * v.w);
362 template<
typename Type>
371 template<
typename Type>
2D vector
Definition: line.h:43
Type x
Definition: vec3.h:74
3D vector
Definition: line_ray.h:43
Type x
Definition: vec4.h:74
Vec4< Type > & operator=(const Vec4< Type > &vector)
= operator.
Definition: vec4.h:282
Vec4(const Vec2< Type > ©, const Vec2< Type > ©34)
Definition: vec4.h:82
Type x
Definition: vec2.h:75
static Vec4< Type > cross3(const Vec4< Type > &vector1, const Vec4< Type > &vector2)
Calculate the cross product between two vectors (not taking into account the w ordinate).
void operator+=(const Vec4< Type > &vector)
+= operator.
Definition: vec4.h:255
*Type length3() const
Returns the length (magnitude) of this vector (not taking into account the w ordinate).
Definition: vec4.h:363
Vec2< Type > operator-(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:272
static Type dot4(const Vec4< Type > &vector1, const Vec4< Type > &vector2)
Dot products between two vectors (taking into account the w ordinate).
Definition: vec4.h:118
Vec4< Type > & round()
Rounds all components on this vector.
static Vec4< Type > rotate3(const Vec4< Type > &vector, Type angle, const Vec4< Type > &axis)
Rotate a vector around an axis. Same as glRotate[f|d](angle, a);.
Vec4(const Type &scalar)
Definition: vec4.h:80
Vec2< Type > operator+(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:260
Type z
Definition: vec3.h:76
*Type length4() const
Returns the length (magnitude) of this vector (taking into account the w ordinate).
Definition: vec4.h:372
Vec4(const Type &p1, const Type &p2, const Type &p3, const Type &p4)
Definition: vec4.h:84
Vec4(const Type &p1, const Type &p2, const Vec2< Type > ©34)
Definition: vec4.h:85
void set_zw(const Vec2< Type > &new_v)
Definition: vec4.h:158
Type datatype
Definition: vec4.h:72
Type y
Definition: vec2.h:76
static bool is_equal(const Vec4< Type > &first, const Vec4< Type > &second, Type epsilon)
Returns true if equal within the bounds of an epsilon.
Definition: vec4.h:151
static Type dot3(const Vec4< Type > &vector1, const Vec4< Type > &vector2)
Dot products between two vectors (not taking into account the w ordinate).
Definition: vec4.h:109
Vec4< Type > & normalize3()
Normalizes this vector (not taking into account the w ordinate)
Vec4(const Vec2< Type > ©, const Type &p3, const Type &p4)
Definition: vec4.h:81
Type y
Definition: vec4.h:75
Vec4()
Definition: vec4.h:79
Type w
Definition: vec4.h:77
Vec2< Type > operator/(const Vec2< Type > &v1, const Vec2< Type > &v2)
/ operator.
Definition: vec2.h:296
Type distance3(const Vec4< Type > &vector) const
Calculate the distance between this vector and an other vector (not taking into account the w ordinat...
Type dot3(const Vec4< Type > &vector) const
Dot products this vector with an other vector (not taking into account the w ordinate).
Definition: vec4.h:192
bool operator!=(const Vec4< Type > &vector) const
!= operator.
Definition: vec4.h:288
Vec4(const Vec3< Type > ©, const Type &p4)
Definition: vec4.h:83
Vec4< Type > operator-() const
operator.
Definition: vec4.h:267
Type dot4(const Vec4< Type > &vector) const
Dot products this vector with an other vector (taking into account the w ordinate).
Definition: vec4.h:200
Vec2< Type > operator*(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:284
Type y
Definition: vec3.h:75
Type z
Definition: vec4.h:76
void operator*=(const Vec4< Type > &vector)
*= operator.
Definition: vec4.h:270
void set_xy(const Vec2< Type > &new_v)
Definition: vec4.h:157
Type angle3(const Vec4< Type > &vector) const
Calculate the angle between this vector and an other vector (not taking into account the w ordinate)...
Vec4< Type > & normalize4()
Normalizes this vector (taking into account the w ordinate)
bool is_equal(const Vec4< Type > &other, Type epsilon) const
Returns true if equal within the bounds of an epsilon.
Definition: vec4.h:252
Definition: Application/application.h:35
void operator/=(const Vec4< Type > &vector)
/= operator.
Definition: vec4.h:276
4D matrix
Definition: mat2.h:47
4D vector
Definition: size.h:44
Vec4(const Type *array_xyzw)
Definition: vec4.h:86
void operator-=(const Vec4< Type > &vector)
-= operator.
Definition: vec4.h:261
Type distance4(const Vec4< Type > &vector) const
Calculate the distance between this vector and an other vector (taking into account the w ordinate)...
bool operator==(const Vec4< Type > &vector) const
== operator.
Definition: vec4.h:285