Voltray Engine Docs
Loading...
Searching...
No Matches
Vec4.h
Go to the documentation of this file.
1#pragma once
2
3#include "Vec2.h"
4#include "Vec3.h"
5
6struct Vec4
7{
8public:
9 float x, y, z, w;
10
11 // Constructors
12 Vec4();
13 Vec4(float x, float y, float z, float w);
14 Vec4(const Vec4 &other);
15
16 // Assignment operator
17 Vec4 &operator=(const Vec4 &other);
18
19 // Arithmetic operators
20 Vec4 operator+(const Vec4 &other) const;
21 Vec4 operator-(const Vec4 &other) const;
22 Vec4 operator*(float scalar) const;
23 Vec4 operator/(float scalar) const;
24
25 // Compound assignment operators
26 Vec4 &operator+=(const Vec4 &other);
27 Vec4 &operator-=(const Vec4 &other);
28 Vec4 &operator*=(float scalar);
29 Vec4 &operator/=(float scalar);
30
31 // Comparison operators
32 bool operator==(const Vec4 &other) const;
33 bool operator!=(const Vec4 &other) const;
34
35 // Scaler
36 Vec4 operator-() const { return Vec4(-x, -y, -z, -w); }
37 Vec4 operator*(const Vec4 &other) const { return Vec4(x * other.x, y * other.y, z * other.z, w * other.w); }
38
39 // Utility functions
40 float length() const;
41 float lengthSquared() const;
42 Vec4 normalized() const;
43 void normalize();
44 float dot(const Vec4 &other) const;
45
46 // Vector component accessors
47 Vec2 xx() const { return Vec2(x, x); }
48 Vec2 xy() const { return Vec2(x, y); }
49 Vec2 xz() const { return Vec2(x, z); }
50 Vec2 xw() const { return Vec2(x, w); }
51 Vec2 yx() const { return Vec2(y, x); }
52 Vec2 yy() const { return Vec2(y, y); }
53 Vec2 yz() const { return Vec2(y, z); }
54 Vec2 yw() const { return Vec2(y, w); }
55 Vec2 zx() const { return Vec2(z, x); }
56 Vec2 zy() const { return Vec2(z, y); }
57 Vec2 zz() const { return Vec2(z, z); }
58 Vec2 zw() const { return Vec2(z, w); }
59 Vec2 wx() const { return Vec2(w, x); }
60 Vec2 wy() const { return Vec2(w, y); }
61 Vec2 wz() const { return Vec2(w, z); }
62 Vec2 ww() const { return Vec2(w, w); }
63
64 Vec3 xxx() const { return Vec3(x, x, x); }
65 Vec3 xxy() const { return Vec3(x, x, y); }
66 Vec3 xxz() const { return Vec3(x, x, z); }
67 Vec3 xxw() const { return Vec3(x, x, w); }
68 Vec3 xyx() const { return Vec3(x, y, x); }
69 Vec3 xyy() const { return Vec3(x, y, y); }
70 Vec3 xyz() const { return Vec3(x, y, z); }
71 Vec3 xyw() const { return Vec3(x, y, w); }
72 Vec3 xzx() const { return Vec3(x, z, x); }
73 Vec3 xzy() const { return Vec3(x, z, y); }
74 Vec3 xzz() const { return Vec3(x, z, z); }
75 Vec3 xzw() const { return Vec3(x, z, w); }
76 Vec3 xwx() const { return Vec3(x, w, x); }
77 Vec3 xwy() const { return Vec3(x, w, y); }
78 Vec3 xwz() const { return Vec3(x, w, z); }
79 Vec3 xww() const { return Vec3(x, w, w); }
80 Vec3 yxx() const { return Vec3(y, x, x); }
81 Vec3 yxy() const { return Vec3(y, x, y); }
82 Vec3 yxz() const { return Vec3(y, x, z); }
83 Vec3 yxw() const { return Vec3(y, x, w); }
84 Vec3 yyx() const { return Vec3(y, y, x); }
85 Vec3 yyy() const { return Vec3(y, y, y); }
86 Vec3 yyz() const { return Vec3(y, y, z); }
87 Vec3 yyw() const { return Vec3(y, y, w); }
88 Vec3 yzx() const { return Vec3(y, z, x); }
89 Vec3 yzy() const { return Vec3(y, z, y); }
90 Vec3 yzz() const { return Vec3(y, z, z); }
91 Vec3 yzw() const { return Vec3(y, z, w); }
92 Vec3 ywx() const { return Vec3(y, w, x); }
93 Vec3 ywy() const { return Vec3(y, w, y); }
94 Vec3 ywz() const { return Vec3(y, w, z); }
95 Vec3 yww() const { return Vec3(y, w, w); }
96 Vec3 zxx() const { return Vec3(z, x, x); }
97 Vec3 zxy() const { return Vec3(z, x, y); }
98 Vec3 zxz() const { return Vec3(z, x, z); }
99 Vec3 zxw() const { return Vec3(z, x, w); }
100 Vec3 zyx() const { return Vec3(z, y, x); }
101 Vec3 zyy() const { return Vec3(z, y, y); }
102 Vec3 zyz() const { return Vec3(z, y, z); }
103 Vec3 zyw() const { return Vec3(z, y, w); }
104 Vec3 zzx() const { return Vec3(z, z, x); }
105 Vec3 zzy() const { return Vec3(z, z, y); }
106 Vec3 zzz() const { return Vec3(z, z, z); }
107 Vec3 zzw() const { return Vec3(z, z, w); }
108 Vec3 zwx() const { return Vec3(z, w, x); }
109 Vec3 zwy() const { return Vec3(z, w, y); }
110 Vec3 zwz() const { return Vec3(z, w, z); }
111 Vec3 zww() const { return Vec3(z, w, w); }
112 Vec3 wxx() const { return Vec3(w, x, x); }
113 Vec3 wxy() const { return Vec3(w, x, y); }
114 Vec3 wxz() const { return Vec3(w, x, z); }
115 Vec3 wxw() const { return Vec3(w, x, w); }
116 Vec3 wyx() const { return Vec3(w, y, x); }
117 Vec3 wyy() const { return Vec3(w, y, y); }
118 Vec3 wyz() const { return Vec3(w, y, z); }
119 Vec3 wyw() const { return Vec3(w, y, w); }
120 Vec3 wzx() const { return Vec3(w, z, x); }
121 Vec3 wzy() const { return Vec3(w, z, y); }
122 Vec3 wzz() const { return Vec3(w, z, z); }
123 Vec3 wzw() const { return Vec3(w, z, w); }
124 Vec3 wwx() const { return Vec3(w, w, x); }
125 Vec3 wwy() const { return Vec3(w, w, y); }
126 Vec3 wwz() const { return Vec3(w, w, z); }
127 Vec3 www() const { return Vec3(w, w, w); }
128
129 // Array access
130 float &operator[](int index);
131 const float &operator[](int index) const;
132};
Represents a 2-dimensional vector with float components.
Definition Vec2.h:8
Definition Vec3.h:5
Definition Vec4.h:7
Vec4 normalized() const
Definition Vec4.cpp:117
Vec3 wwz() const
Definition Vec4.h:126
Vec2 xy() const
Definition Vec4.h:48
Vec3 zxx() const
Definition Vec4.h:96
float lengthSquared() const
Definition Vec4.cpp:112
Vec4 operator*(const Vec4 &other) const
Definition Vec4.h:37
Vec3 xyy() const
Definition Vec4.h:69
Vec3 yyz() const
Definition Vec4.h:86
Vec3 wyw() const
Definition Vec4.h:119
Vec3 xzz() const
Definition Vec4.h:74
Vec4 & operator/=(float scalar)
Definition Vec4.cpp:78
Vec4 operator-() const
Definition Vec4.h:36
Vec2 zx() const
Definition Vec4.h:55
Vec3 yyx() const
Definition Vec4.h:84
Vec3 xxw() const
Definition Vec4.h:67
Vec3 zyw() const
Definition Vec4.h:103
Vec3 yzy() const
Definition Vec4.h:89
Vec3 zyy() const
Definition Vec4.h:101
Vec3 yyy() const
Definition Vec4.h:85
float y
Definition Vec4.h:9
Vec3 yxx() const
Definition Vec4.h:80
Vec3 zxz() const
Definition Vec4.h:98
float & operator[](int index)
Definition Vec4.cpp:142
Vec3 xxz() const
Definition Vec4.h:66
Vec3 xzy() const
Definition Vec4.h:73
Vec2 xx() const
Definition Vec4.h:47
Vec3 yzz() const
Definition Vec4.h:90
Vec4 & operator-=(const Vec4 &other)
Definition Vec4.cpp:60
float w
Definition Vec4.h:9
Vec3 wyx() const
Definition Vec4.h:116
Vec3 xwy() const
Definition Vec4.h:77
Vec2 zy() const
Definition Vec4.h:56
Vec3 ywx() const
Definition Vec4.h:92
Vec3 xxx() const
Definition Vec4.h:64
bool operator==(const Vec4 &other) const
Definition Vec4.cpp:92
float x
Definition Vec4.h:9
Vec3 ywz() const
Definition Vec4.h:94
Vec3 zyz() const
Definition Vec4.h:102
Vec3 wyy() const
Definition Vec4.h:117
Vec3 zwy() const
Definition Vec4.h:109
Vec3 zxw() const
Definition Vec4.h:99
Vec3 wzx() const
Definition Vec4.h:120
Vec3 xwz() const
Definition Vec4.h:78
Vec3 wxy() const
Definition Vec4.h:113
Vec4()
Definition Vec4.cpp:6
bool operator!=(const Vec4 &other) const
Definition Vec4.cpp:101
Vec4 & operator+=(const Vec4 &other)
Definition Vec4.cpp:51
Vec3 zxy() const
Definition Vec4.h:97
float z
Definition Vec4.h:9
Vec4 & operator*=(float scalar)
Definition Vec4.cpp:69
Vec3 zzw() const
Definition Vec4.h:107
Vec4 operator+(const Vec4 &other) const
Definition Vec4.cpp:26
Vec2 wz() const
Definition Vec4.h:61
Vec3 xzx() const
Definition Vec4.h:72
Vec3 wzy() const
Definition Vec4.h:121
Vec3 wxz() const
Definition Vec4.h:114
Vec3 yxz() const
Definition Vec4.h:82
Vec3 xwx() const
Definition Vec4.h:76
Vec3 yxw() const
Definition Vec4.h:83
Vec2 xz() const
Definition Vec4.h:49
Vec2 yw() const
Definition Vec4.h:54
Vec3 ywy() const
Definition Vec4.h:93
Vec2 xw() const
Definition Vec4.h:50
Vec3 wwy() const
Definition Vec4.h:125
Vec3 wyz() const
Definition Vec4.h:118
Vec3 xyx() const
Definition Vec4.h:68
Vec3 wxx() const
Definition Vec4.h:112
Vec3 zwz() const
Definition Vec4.h:110
Vec2 zz() const
Definition Vec4.h:57
float dot(const Vec4 &other) const
Definition Vec4.cpp:136
Vec3 wzz() const
Definition Vec4.h:122
Vec2 yy() const
Definition Vec4.h:52
Vec3 xzw() const
Definition Vec4.h:75
Vec2 yx() const
Definition Vec4.h:51
Vec3 zww() const
Definition Vec4.h:111
Vec3 yzx() const
Definition Vec4.h:88
Vec3 xww() const
Definition Vec4.h:79
Vec2 zw() const
Definition Vec4.h:58
Vec3 zwx() const
Definition Vec4.h:108
float length() const
Definition Vec4.cpp:107
Vec4 operator/(float scalar) const
Definition Vec4.cpp:41
Vec4 operator*(float scalar) const
Definition Vec4.cpp:36
Vec2 wy() const
Definition Vec4.h:60
Vec3 zzz() const
Definition Vec4.h:106
Vec3 xyz() const
Definition Vec4.h:70
Vec2 yz() const
Definition Vec4.h:53
Vec3 yzw() const
Definition Vec4.h:91
Vec3 zyx() const
Definition Vec4.h:100
Vec3 yyw() const
Definition Vec4.h:87
Vec3 yww() const
Definition Vec4.h:95
Vec2 wx() const
Definition Vec4.h:59
Vec3 zzx() const
Definition Vec4.h:104
Vec2 ww() const
Definition Vec4.h:62
Vec3 yxy() const
Definition Vec4.h:81
Vec3 www() const
Definition Vec4.h:127
void normalize()
Definition Vec4.cpp:127
Vec3 wwx() const
Definition Vec4.h:124
Vec3 wxw() const
Definition Vec4.h:115
Vec3 xyw() const
Definition Vec4.h:71
Vec4 & operator=(const Vec4 &other)
Definition Vec4.cpp:13
Vec3 xxy() const
Definition Vec4.h:65
Vec3 wzw() const
Definition Vec4.h:123
Vec3 zzy() const
Definition Vec4.h:105