@@ -26,108 +26,176 @@ class Vector2 : public ::Vector2 {
2626 GETTERSETTER (float , X, x)
2727 GETTERSETTER (float , Y, y)
2828
29+ /* *
30+ * Set the Vector2 to the same as the given Vector2.
31+ */
2932 Vector2& operator =(const ::Vector2& vector2) {
3033 set (vector2);
3134 return *this ;
3235 }
3336
37+ /* *
38+ * Determine whether or not the vectors are equal.
39+ */
3440 bool operator ==(const ::Vector2& other) {
3541 return x == other.x
3642 && y == other.y ;
3743 }
3844
45+ /* *
46+ * Determines if the vectors are not equal.
47+ */
3948 bool operator !=(const ::Vector2& other) {
4049 return !(*this == other);
4150 }
4251
4352#ifndef RAYLIB_CPP_NO_MATH
44- Vector2 Add (const ::Vector2& vector2) const {
53+ /* *
54+ * Add two vectors (v1 + v2)
55+ */
56+ inline Vector2 Add (const ::Vector2& vector2) const {
4557 return Vector2Add (*this , vector2);
4658 }
4759
48- Vector2 operator +(const ::Vector2& vector2) const {
60+ /* *
61+ * Add two vectors (v1 + v2)
62+ */
63+ inline Vector2 operator +(const ::Vector2& vector2) const {
4964 return Vector2Add (*this , vector2);
5065 }
5166
52- Vector2 Subtract (const ::Vector2& vector2) const {
67+ /* *
68+ * Add two vectors (v1 + v2)
69+ */
70+ Vector2& operator +=(const ::Vector2& vector2) {
71+ set (Vector2Add (*this , vector2));
72+
73+ return *this ;
74+ }
75+
76+ /* *
77+ * Subtract two vectors (v1 - v2)
78+ */
79+ inline Vector2 Subtract (const ::Vector2& vector2) const {
5380 return Vector2Subtract (*this , vector2);
5481 }
5582
56- Vector2 operator -(const ::Vector2& vector2) const {
83+ /* *
84+ * Subtract two vectors (v1 - v2)
85+ */
86+ inline Vector2 operator -(const ::Vector2& vector2) const {
5787 return Vector2Subtract (*this , vector2);
5888 }
5989
60- Vector2 Negate () const {
61- return Vector2Negate (*this );
90+ /* *
91+ * Add two vectors (v1 + v2)
92+ */
93+ Vector2& operator -=(const ::Vector2& vector2) {
94+ set (Vector2Subtract (*this , vector2));
95+
96+ return *this ;
6297 }
6398
64- Vector2 operator -() const {
99+ /* *
100+ * Negate vector
101+ */
102+ inline Vector2 Negate () const {
65103 return Vector2Negate (*this );
66104 }
67105
68- Vector2 Multiply (const ::Vector2& vector2) const {
69- return Vector2Multiply (*this , vector2);
106+ /* *
107+ * Negate vector
108+ */
109+ inline Vector2 operator -() const {
110+ return Vector2Negate (*this );
70111 }
71112
72- Vector2 operator *(const ::Vector2& vector2) const {
113+ /* *
114+ * Multiply vector by vector
115+ */
116+ inline Vector2 Multiply (const ::Vector2& vector2) const {
73117 return Vector2Multiply (*this , vector2);
74118 }
75119
76- Vector2 Scale (const float scale) const {
77- return Vector2Scale (*this , scale);
78- }
79-
80- Vector2 operator *(const float scale) const {
81- return Vector2Scale (*this , scale);
120+ /* *
121+ * Multiply vector by vector
122+ */
123+ inline Vector2 operator *(const ::Vector2& vector2) const {
124+ return Vector2Multiply (*this , vector2);
82125 }
83126
84- Vector2 Divide (const ::Vector2& vector2) const {
85- return Vector2Divide (*this , vector2);
86- }
127+ /* *
128+ * Multiply vector by vector
129+ */
130+ Vector2& operator *=(const ::Vector2& vector2) {
131+ set (Vector2Multiply (*this , vector2));
87132
88- Vector2 operator /(const ::Vector2& vector2) const {
89- return Vector2Divide (*this , vector2);
133+ return *this ;
90134 }
91135
92- Vector2 Divide (const float div) const {
93- return ::Vector2{x / div, y / div};
136+ /* *
137+ * Scale vector (multiply by value)
138+ */
139+ inline Vector2 Scale (const float scale) const {
140+ return Vector2Scale (*this , scale);
94141 }
95142
96- Vector2 operator /(const float div) const {
97- return Divide (div);
143+ /* *
144+ * Scale vector (multiply by value)
145+ */
146+ inline Vector2 operator *(const float scale) const {
147+ return Vector2Scale (*this , scale);
98148 }
99149
100- Vector2& operator +=(const ::Vector2& vector2) {
101- set (Vector2Add (*this , vector2));
150+ /* *
151+ * Scale vector (multiply by value)
152+ */
153+ Vector2& operator *=(const float scale) {
154+ set (Vector2Scale (*this , scale));
102155
103156 return *this ;
104157 }
105158
106- Vector2& operator -=(const ::Vector2& vector2) {
107- set (Vector2Subtract (*this , vector2));
108-
109- return *this ;
159+ /* *
160+ * Divide vector by vector
161+ */
162+ inline Vector2 Divide (const ::Vector2& vector2) const {
163+ return Vector2Divide (*this , vector2);
110164 }
111165
112-
113- Vector2& operator *=( const ::Vector2& vector2) {
114- set ( Vector2Multiply (* this , vector2));
115-
116- return *this ;
166+ /* *
167+ * Divide vector by vector
168+ */
169+ inline Vector2 operator /( const ::Vector2& vector2) const {
170+ return Vector2Divide ( *this , vector2) ;
117171 }
118172
119- Vector2& operator *=(const float scale) {
120- set (Vector2Scale (*this , scale));
173+ /* *
174+ * Divide vector by vector
175+ */
176+ Vector2& operator /=(const ::Vector2& vector2) {
177+ set (Vector2Divide (*this , vector2));
121178
122179 return *this ;
123180 }
124181
125- Vector2& operator /=(const ::Vector2& vector2) {
126- set (Vector2Divide (*this , vector2));
182+ /* *
183+ * Divide vector by value
184+ */
185+ inline Vector2 Divide (const float div) const {
186+ return ::Vector2{x / div, y / div};
187+ }
127188
128- return *this ;
189+ /* *
190+ * Divide vector by value
191+ */
192+ inline Vector2 operator /(const float div) const {
193+ return Divide (div);
129194 }
130195
196+ /* *
197+ * Divide vector by value
198+ */
131199 Vector2& operator /=(const float div) {
132200 this ->x /= div;
133201 this ->y /= div;
@@ -138,84 +206,84 @@ class Vector2 : public ::Vector2 {
138206 /* *
139207 * Calculate vector length
140208 */
141- float Length () const {
209+ inline float Length () const {
142210 return Vector2Length (*this );
143211 }
144212
145213 /* *
146214 * Calculate vector square length
147215 */
148- float LengthSqr () const {
216+ inline float LengthSqr () const {
149217 return Vector2LengthSqr (*this );
150218 }
151219
152220 /* *
153221 * Normalize provided vector
154222 */
155- Vector2 Normalize () const {
223+ inline Vector2 Normalize () const {
156224 return Vector2Normalize (*this );
157225 }
158226
159227 /* *
160228 * Calculate two vectors dot product
161229 */
162- float DotProduct (const ::Vector2& vector2) const {
230+ inline float DotProduct (const ::Vector2& vector2) const {
163231 return Vector2DotProduct (*this , vector2);
164232 }
165233
166234 /* *
167235 * Calculate angle from two vectors in X-axis
168236 */
169- float Angle (const ::Vector2& vector2) const {
237+ inline float Angle (const ::Vector2& vector2) const {
170238 return Vector2Angle (*this , vector2);
171239 }
172240
173241 /* *
174242 * Calculate distance between two vectors
175243 */
176- float Distance (const ::Vector2& vector2) const {
244+ inline float Distance (const ::Vector2& vector2) const {
177245 return Vector2Distance (*this , vector2);
178246 }
179247
180248 /* *
181249 * Calculate linear interpolation between two vectors
182250 */
183- Vector2 Lerp (const ::Vector2& vector2, float amount) const {
251+ inline Vector2 Lerp (const ::Vector2& vector2, float amount) const {
184252 return Vector2Lerp (*this , vector2, amount);
185253 }
186254
187255 /* *
188256 * Calculate reflected vector to normal
189257 */
190- Vector2 Reflect (const ::Vector2& normal) const {
258+ inline Vector2 Reflect (const ::Vector2& normal) const {
191259 return Vector2Reflect (*this , normal);
192260 }
193261
194262 /* *
195263 * Rotate Vector by float in Degrees
196264 */
197- Vector2 Rotate (float degrees) const {
265+ inline Vector2 Rotate (float degrees) const {
198266 return Vector2Rotate (*this , degrees);
199267 }
200268
201269 /* *
202270 * Move Vector towards target
203271 */
204- Vector2 MoveTowards (const ::Vector2& target, float maxDistance) const {
272+ inline Vector2 MoveTowards (const ::Vector2& target, float maxDistance) const {
205273 return Vector2MoveTowards (*this , target, maxDistance);
206274 }
207275
208276 /* *
209277 * Vector with components value 0.0f
210278 */
211- static Vector2 Zero () {
279+ static inline Vector2 Zero () {
212280 return Vector2Zero ();
213281 }
214282
215283 /* *
216284 * Vector with components value 1.0f
217285 */
218- static Vector2 One () {
286+ static inline Vector2 One () {
219287 return Vector2One ();
220288 }
221289#endif
0 commit comments