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>
63 template<
typename Type>
73 template<
typename Type>
79 union { Type
x; Type
s; Type
r; };
80 union { Type
y; Type
t; Type
g; };
81 union { Type
z; Type
u; Type
b; };
82 union { Type
w; Type
v; Type
a; };
85 explicit Vec4(
const Type &scalar) :
x(scalar),
y(scalar),
z(scalar),
w(scalar) { }
86 explicit Vec4(
const Vec2<Type> ©,
const Type &p3,
const Type &p4) :
x(copy.
x),
y(copy.
y),
z(p3),
w(p4) {}
89 explicit Vec4(
const Type &p1,
const Type &p2,
const Type &p3,
const Type &p4) :
x(p1),
y(p2),
z(p3),
w(p4) { }
90 explicit Vec4(
const Type &p1,
const Type &p2,
const Vec2<Type> ©34) :
x(p1),
y(p2),
z(copy34.
x),
w(copy34.
y) { }
91 explicit Vec4(
const Type *array_xyzw) :
x(array_xyzw[0]),
y(array_xyzw[1]),
z(array_xyzw[2]),
w(array_xyzw[3]) { }
95 template<typename OtherType, typename std::enable_if_t<std::is_integral<Type>::value && !std::is_integral<OtherType>::value,
int> = 0>
96 Vec4(
const Vec4<OtherType>& copy) :
x(static_cast<Type>(std::floor(copy.
x + 0.5f))),
y(static_cast<Type>(std::floor(copy.
y + 0.5f))),
z(static_cast<Type>(std::floor(copy.
z + 0.5f))),
w(static_cast<Type>(std::floor(copy.
z + 0.5f))) {}
98 template<typename OtherType, typename std::enable_if_t<!std::is_integral<Type>::value || std::is_integral<OtherType>::value,
int> = 0>
99 Vec4(
const Vec4<OtherType>& copy) :
x(static_cast<Type>(copy.
x)),
y(static_cast<Type>(copy.
y)),
z(static_cast<Type>(copy.
z)),
w(static_cast<Type>(copy.
z)) {}
166 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;
167 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);
304 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))))); }
308 template<
typename Type>
312 template<
typename Type>
316 template<
typename Type>
320 template<
typename Type>
324 template<
typename Type>
328 template<
typename Type>
332 template<
typename Type>
336 template<
typename Type>
340 template<
typename Type>
344 template<
typename Type>
348 template<
typename Type>
352 template<
typename Type>
355 template<
typename Type>
359 matrix[0 * 4 + 0] *
v.x + matrix[0 * 4 + 1] *
v.y + matrix[0 * 4 + 2] *
v.z + matrix[0 * 4 + 3] *
v.w,
360 matrix[1 * 4 + 0] *
v.x + matrix[1 * 4 + 1] *
v.y + matrix[1 * 4 + 2] *
v.z + matrix[1 * 4 + 3] *
v.w,
361 matrix[2 * 4 + 0] *
v.x + matrix[2 * 4 + 1] *
v.y + matrix[2 * 4 + 2] *
v.z + matrix[2 * 4 + 3] *
v.w,
362 matrix[3 * 4 + 0] *
v.x + matrix[3 * 4 + 1] *
v.y + matrix[3 * 4 + 2] *
v.z + matrix[3 * 4 + 3] *
v.w);
365 template<
typename Type>
369 matrix[0 * 4 + 0] *
v.x + matrix[1 * 4 + 0] *
v.y + matrix[2 * 4 + 0] *
v.z + matrix[3 * 4 + 0] *
v.w,
370 matrix[0 * 4 + 1] *
v.x + matrix[1 * 4 + 1] *
v.y + matrix[2 * 4 + 1] *
v.z + matrix[3 * 4 + 1] *
v.w,
371 matrix[0 * 4 + 2] *
v.x + matrix[1 * 4 + 2] *
v.y + matrix[2 * 4 + 2] *
v.z + matrix[3 * 4 + 2] *
v.w,
372 matrix[0 * 4 + 3] *
v.x + matrix[1 * 4 + 3] *
v.y + matrix[2 * 4 + 3] *
v.z + matrix[3 * 4 + 3] *
v.w);
375 template<
typename Type>
384 template<
typename Type>
Angle class.
Definition angle.h:60
Mat2()
Constructs a 2x2 matrix (zero'ed)
Definition mat2.h:62
Mat3()
Constructs a 3x3 matrix (zero'ed)
Definition mat3.h:63
4D matrix
Definition vec4.h:58
Mat4()
Constructs a 4x4 matrix (zero'ed)
Definition mat4.h:81
Pointx()
Definition point.h:54
Sizex()
Constructs a size structure.
Definition size.h:58
2D vector
Definition vec4.h:43
Type y
Definition vec2.h:81
Vec2()
Definition vec2.h:83
Type x
Definition vec2.h:80
3D vector
Definition vec4.h:46
Vec3()
Definition vec3.h:83
4D vector
Definition vec4.h:75
unsigned char u
Definition vec4.h:81
unsigned char s
Definition vec4.h:79
bool operator!=(const Vec4< Type > &vector) const
!= operator.
Definition vec4.h:301
unsigned char a
Definition vec4.h:82
unsigned char r
Definition vec4.h:79
Vec4< Type > & operator=(const Vec4< Type > &vector)=default
= operator.
unsigned char z
Definition vec4.h:81
static Vec4< Type > rotate3(const Vec4< Type > &vector, const Angle &angle, const Vec4< Type > &axis)
Rotate a vector around an axis. Same as glRotate[f|d](angle, a);.
Vec4(const Vec2< Type > ©, const Type &p3, const Type &p4)
Definition vec4.h:86
Vec4()
Definition vec4.h:84
void operator*=(const Vec4< Type > &vector)
*= operator.
Definition vec4.h:283
Vec4< Type > & normalize3()
Normalizes this vector (not taking into account the w ordinate)
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:164
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:205
unsigned char y
Definition vec4.h:80
Vec4(const Type &scalar)
Definition vec4.h:85
bool operator==(const Vec4< Type > &vector) const
== operator.
Definition vec4.h:298
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).
Vec4(const Vec4< Type > ©)=default
unsigned char x
Definition vec4.h:79
void set_xy(const Vec2< Type > &new_v)
Definition vec4.h:170
unsigned char v
Definition vec4.h:82
Vec4< Type > operator-() const
operator.
Definition vec4.h:280
Angle 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)
static Vec4< Type > round(const Vec4< Type > &vector)
Rounds all components on a vector.
Type distance3(const Vec4< Type > &vector) const
Calculate the distance between this vector and an other vector (not taking into account the w ordinat...
Vec4< Type > & rotate3(const Angle &angle, const Vec4< Type > &axis)
Rotate this vector around an axis. Same as glRotate[f|d](angle, a);.
static Vec4< Type > normalize4(const Vec4< Type > &vector)
Normalizes a vector (taking into account the w ordinate)
void operator+=(const Vec4< Type > &vector)
+= operator.
Definition vec4.h:268
Vec4(const Vec3< Type > ©, const Type &p4)
Definition vec4.h:88
Vec4(const Vec4< OtherType > ©)
Definition vec4.h:96
Vec4(const Type &p1, const Type &p2, const Type &p3, const Type &p4)
Definition vec4.h:89
Type distance4(const Vec4< Type > &vector) const
Calculate the distance between this vector and an other vector (taking into account the w ordinate).
Vec4(const Vec2< Type > ©, const Vec2< Type > ©34)
Definition vec4.h:87
bool operator<(const Vec4< Type > &vector) const
< operator.
Definition vec4.h:304
unsigned char w
Definition vec4.h:82
Vec4< Type > & round()
Rounds all components on this vector.
Type dot4(const Vec4< Type > &vector) const
Dot products this vector with an other vector (taking into account the w ordinate).
Definition vec4.h:213
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:122
bool is_equal(const Vec4< Type > &other, Type epsilon) const
Returns true if equal within the bounds of an epsilon.
Definition vec4.h:265
Vec4(const Type *array_xyzw)
Definition vec4.h:91
void operator/=(const Vec4< Type > &vector)
/= operator.
Definition vec4.h:289
Type datatype
Definition vec4.h:77
void operator-=(const Vec4< Type > &vector)
-= operator.
Definition vec4.h:274
Vec4(const Type &p1, const Type &p2, const Vec2< Type > ©34)
Definition vec4.h:90
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:131
unsigned char b
Definition vec4.h:81
Vec4< Type > & cross3(const Vec4< Type > &vector)
Calculate the cross product between this vector and an other vector (not taking into account the w or...
unsigned char g
Definition vec4.h:80
static Vec4< Type > normalize3(const Vec4< Type > &vector)
Normalizes a vector (not taking into account the w ordinate)
void set_zw(const Vec2< Type > &new_v)
Definition vec4.h:171
unsigned char t
Definition vec4.h:80
Vec2< Type > operator/(const Vec2< Type > &v1, const Vec2< Type > &v2)
/ operator.
Definition vec2.h:306
Vec4< unsigned char > Vec4ub
Definition vec4.h:393
Type length4() const
Returns the length (magnitude) of this vector (taking into account the w ordinate).
Definition vec4.h:385
Vec4< unsigned int > Vec4ui
Definition vec4.h:397
Vec4< char > Vec4b
Definition vec4.h:394
Vec4< float > Vec4f
Definition vec4.h:399
Vec2< Type > operator-(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition vec2.h:282
Type length3() const
Returns the length (magnitude) of this vector (not taking into account the w ordinate).
Definition vec4.h:376
Vec2< Type > operator+(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition vec2.h:270
Vec4< short > Vec4s
Definition vec4.h:396
Vec4< int > Vec4i
Definition vec4.h:398
Vec4< double > Vec4d
Definition vec4.h:400
Vec2< Type > operator*(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition vec2.h:294
Vec4< unsigned short > Vec4us
Definition vec4.h:395
@ angle
value is a color
Definition style_value_type.h:44