Skip to content

Commit 49c05c5

Browse files
committed
Add in more raymath Vector2 functions
1 parent 3b40345 commit 49c05c5

File tree

1 file changed

+72
-30
lines changed

1 file changed

+72
-30
lines changed

include/Vector2.hpp

Lines changed: 72 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -202,73 +202,115 @@ class Vector2 : public ::Vector2 {
202202
}
203203

204204
/**
205-
* Calculate vector length
205+
* Normalize provided vector
206206
*/
207-
inline float Length() const {
208-
return Vector2Length(*this);
207+
inline Vector2 Normalize() const {
208+
return Vector2Normalize(*this);
209209
}
210210

211211
/**
212-
* Calculate vector square length
212+
* Transforms a Vector2 by a given Matrix
213213
*/
214-
inline float LengthSqr() const {
215-
return Vector2LengthSqr(*this);
214+
inline Vector2 Transform(::Matrix mat) {
215+
return ::Vector2Transform(*this, mat);
216216
}
217217

218218
/**
219-
* Normalize provided vector
219+
* Calculate linear interpolation between two vectors
220220
*/
221-
inline Vector2 Normalize() const {
222-
return Vector2Normalize(*this);
221+
inline Vector2 Lerp(const ::Vector2& vector2, float amount) const {
222+
return Vector2Lerp(*this, vector2, amount);
223223
}
224224

225225
/**
226-
* Calculate two vectors dot product
226+
* Calculate reflected vector to normal
227227
*/
228-
inline float DotProduct(const ::Vector2& vector2) const {
229-
return Vector2DotProduct(*this, vector2);
228+
inline Vector2 Reflect(const ::Vector2& normal) const {
229+
return Vector2Reflect(*this, normal);
230230
}
231231

232232
/**
233-
* Calculate angle from two vectors in X-axis
233+
* Rotate Vector by float in Degrees
234234
*/
235-
inline float Angle(const ::Vector2& vector2) const {
236-
return Vector2Angle(*this, vector2);
235+
inline Vector2 Rotate(float degrees) const {
236+
return Vector2Rotate(*this, degrees);
237237
}
238238

239239
/**
240-
* Calculate distance between two vectors
240+
* Move Vector towards target
241241
*/
242-
inline float Distance(const ::Vector2& vector2) const {
243-
return Vector2Distance(*this, vector2);
242+
inline Vector2 MoveTowards(const ::Vector2& target, float maxDistance) const {
243+
return Vector2MoveTowards(*this, target, maxDistance);
244244
}
245245

246246
/**
247-
* Calculate linear interpolation between two vectors
247+
* Invert the given vector
248248
*/
249-
inline Vector2 Lerp(const ::Vector2& vector2, float amount) const {
250-
return Vector2Lerp(*this, vector2, amount);
249+
inline Vector2 Invert() {
250+
return ::Vector2Invert(*this);
251251
}
252252

253253
/**
254-
* Calculate reflected vector to normal
254+
* Clamp the components of the vector between
255255
*/
256-
inline Vector2 Reflect(const ::Vector2& normal) const {
257-
return Vector2Reflect(*this, normal);
256+
inline Vector2 Clamp(::Vector2 min, ::Vector2 max) {
257+
return ::Vector2Clamp(*this, min, max);
258258
}
259259

260260
/**
261-
* Rotate Vector by float in Degrees
261+
* // Clamp the magnitude of the vector between two min and max values
262262
*/
263-
inline Vector2 Rotate(float degrees) const {
264-
return Vector2Rotate(*this, degrees);
263+
inline Vector2 Clamp(float min, float max) {
264+
return ::Vector2ClampValue(*this, min, max);
265265
}
266266

267267
/**
268-
* Move Vector towards target
268+
* Check whether two given vectors are almost equal
269269
*/
270-
inline Vector2 MoveTowards(const ::Vector2& target, float maxDistance) const {
271-
return Vector2MoveTowards(*this, target, maxDistance);
270+
inline int Equals(::Vector2 q) {
271+
return ::Vector2Equals(*this, q);
272+
}
273+
274+
/**
275+
* Calculate vector length
276+
*/
277+
inline float Length() const {
278+
return Vector2Length(*this);
279+
}
280+
281+
/**
282+
* Calculate vector square length
283+
*/
284+
inline float LengthSqr() const {
285+
return Vector2LengthSqr(*this);
286+
}
287+
288+
/**
289+
* Calculate two vectors dot product
290+
*/
291+
inline float DotProduct(const ::Vector2& vector2) const {
292+
return Vector2DotProduct(*this, vector2);
293+
}
294+
295+
/**
296+
* Calculate distance between two vectors
297+
*/
298+
inline float Distance(const ::Vector2& vector2) const {
299+
return Vector2Distance(*this, vector2);
300+
}
301+
302+
/**
303+
* Calculate square distance between two vectors
304+
*/
305+
inline float DistanceSqr(::Vector2 v2) {
306+
return ::Vector2DistanceSqr(*this, v2);
307+
}
308+
309+
/**
310+
* Calculate angle from two vectors in X-axis
311+
*/
312+
inline float Angle(const ::Vector2& vector2) const {
313+
return Vector2Angle(*this, vector2);
272314
}
273315

274316
/**

0 commit comments

Comments
 (0)