Skip to content

Commit d82a855

Browse files
committed
Add vector add/sub float operations
- Vector2 add/sub float operations - Vector3 add/sub float operations
1 parent 3f02978 commit d82a855

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

include/Vector2.hpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,29 @@ class Vector2 : public ::Vector2 {
6868
return *this;
6969
}
7070

71+
/**
72+
* Add vector and float value
73+
*/
74+
Vector2 Add(float value) const {
75+
return Vector2AddValue(*this, value);
76+
}
77+
78+
/**
79+
* Add vector and float value
80+
*/
81+
Vector2 operator+(float value) const {
82+
return Vector2AddValue(*this, value);
83+
}
84+
85+
/**
86+
* Add vector and float value
87+
*/
88+
Vector2& operator+=(float value) {
89+
set(Vector2AddValue(*this, value));
90+
91+
return *this;
92+
}
93+
7194
/**
7295
* Subtract two vectors (v1 - v2)
7396
*/
@@ -87,6 +110,29 @@ class Vector2 : public ::Vector2 {
87110
return *this;
88111
}
89112

113+
/**
114+
* Subtract vector by float value
115+
*/
116+
[[nodiscard]] Vector2 Subtract(float value) const {
117+
return Vector2SubtractValue(*this, value);
118+
}
119+
120+
/**
121+
* Subtract vector by float value
122+
*/
123+
Vector2 operator-(float value) const {
124+
return Vector2SubtractValue(*this, value);
125+
}
126+
127+
/**
128+
* Subtract vector by float value
129+
*/
130+
Vector2& operator-=(float value) {
131+
set(Vector2SubtractValue(*this, value));
132+
133+
return *this;
134+
}
135+
90136
/**
91137
* Negate vector
92138
*/

include/Vector3.hpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ class Vector3 : public ::Vector3 {
6060
return *this;
6161
}
6262

63+
/**
64+
* Add vector and float value
65+
*/
66+
[[nodiscard]] Vector3 Add(float value) const {
67+
return Vector3AddValue(*this, value);
68+
}
69+
70+
/**
71+
* Add vector and float value
72+
*/
73+
Vector3 operator+(float value) const {
74+
return Vector3AddValue(*this, value);
75+
}
76+
77+
Vector3& operator+=(float value) {
78+
set(Vector3AddValue(*this, value));
79+
80+
return *this;
81+
}
82+
6383
/**
6484
* Subtract two vectors.
6585
*/
@@ -76,6 +96,26 @@ class Vector3 : public ::Vector3 {
7696
return *this;
7797
}
7898

99+
/**
100+
* Subtract vector by float value
101+
*/
102+
[[nodiscard]] Vector3 Subtract(float value) const {
103+
return Vector3SubtractValue(*this, value);
104+
}
105+
106+
/**
107+
* Subtract vector by float value
108+
*/
109+
Vector3 operator-(float value) const {
110+
return Vector3SubtractValue(*this, value);
111+
}
112+
113+
Vector3& operator-=(float value) {
114+
set(Vector3SubtractValue(*this, value));
115+
116+
return *this;
117+
}
118+
79119
/**
80120
* Negate provided vector (invert direction)
81121
*/

0 commit comments

Comments
 (0)