Faro Engine 0.0.0.b519570 (main)
Loading...
Searching...
No Matches
Vector4.hpp
Go to the documentation of this file.
1#pragma once
2#include "../Containers/String.hpp"
3#include "Vector2.hpp"
4#include "Vector3.hpp"
5
6namespace Faro
7{
8 template<class T>
9 struct Vector4
10 {
11 union
12 {
13 T f[4];
14#pragma warning(suppress: 4201)
15 struct { T x, y, z, w; };
16 };
17
19 {
20 Clear();
21 }
22 Vector4(T x, T y, T z, T w) : x(x), y(y), z(z), w(w) {}
23 Vector4(Vector3<T> v, T w) : x(v.x), y(v.y), z(v.z), w(w) {}
24 Vector4(Vector2<T> a, Vector2<T> b) : x(a.x), y(a.y), z(b.x), w(b.y) {}
25
27 {
28 return { x, y, z };
29 }
30
32 {
33 return { x, y };
34 }
35
37 {
38 return { z, w };
39 }
40
42 {
43 return { y, z };
44 }
45
46 void Clear()
47 {
48 x = 0; y = 0; z = 0; w = 0;
49 }
50
51 Vector4 Lerp(const Vector4& r, float fact) const { return Vector4(x + ((r.x - x)*fact), y + ((r.y - y)*fact), z + ((r.z - z)*fact), z + ((r.w - w)*fact)); }
52
54 {
55 return "(x: " + Faro::ToString<T>(x) + ", y: " + Faro::ToString<T>(y) + ", z: " + Faro::ToString<T>(z) + ", w: " + Faro::ToString<T>(w) + ")";
56 }
57
58 template<class N> Vector4<N> ToType()
59 {
60 return Vector4<N>((N)x, (N)y, (N)z, (N)w);
61 }
62
63 static Vector4 zero;
64 static Vector4 one;
65 };
66
67 template<class T> Vector4<T> Vector4<T>::zero = { 0, 0, 0, 0 };
68 template<class T> Vector4<T> Vector4<T>::one = { 1, 1, 1, 1 };
69
72}
Definition String.hpp:12
Definition Array.hpp:8
Vector4< float > Float4D
Definition Vector4.hpp:70
Vector4< int32 > Int4D
Definition Vector4.hpp:71
Definition Vector2.hpp:9
Definition Vector3.hpp:9
Definition Vector4.hpp:10
Vector4 Lerp(const Vector4 &r, float fact) const
Definition Vector4.hpp:51
Vector3< T > xyz()
Definition Vector4.hpp:26
Vector4< N > ToType()
Definition Vector4.hpp:58
T w
Definition Vector4.hpp:15
T y
Definition Vector4.hpp:15
Vector4()
Definition Vector4.hpp:18
Vector4(Vector2< T > a, Vector2< T > b)
Definition Vector4.hpp:24
T z
Definition Vector4.hpp:15
Vector2< T > xy()
Definition Vector4.hpp:31
static Vector4 one
Definition Vector4.hpp:64
Vector4(Vector3< T > v, T w)
Definition Vector4.hpp:23
String ToString()
Definition Vector4.hpp:53
T x
Definition Vector4.hpp:15
void Clear()
Definition Vector4.hpp:46
Vector2< T > zw()
Definition Vector4.hpp:36
static Vector4 zero
Definition Vector4.hpp:63
Vector2< T > yz()
Definition Vector4.hpp:41
Vector4(T x, T y, T z, T w)
Definition Vector4.hpp:22
T f[4]
Definition Vector4.hpp:13