From 49c05c5bfa9d4695a6d4f8a8416fe3b6fee4162d Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Fri, 9 Dec 2022 02:55:56 -0500 Subject: [PATCH] Add in more raymath Vector2 functions --- include/Vector2.hpp | 102 +++++++++++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 30 deletions(-) diff --git a/include/Vector2.hpp b/include/Vector2.hpp index 43b870b7..ca3d3fc7 100644 --- a/include/Vector2.hpp +++ b/include/Vector2.hpp @@ -202,73 +202,115 @@ class Vector2 : public ::Vector2 { } /** - * Calculate vector length + * Normalize provided vector */ - inline float Length() const { - return Vector2Length(*this); + inline Vector2 Normalize() const { + return Vector2Normalize(*this); } /** - * Calculate vector square length + * Transforms a Vector2 by a given Matrix */ - inline float LengthSqr() const { - return Vector2LengthSqr(*this); + inline Vector2 Transform(::Matrix mat) { + return ::Vector2Transform(*this, mat); } /** - * Normalize provided vector + * Calculate linear interpolation between two vectors */ - inline Vector2 Normalize() const { - return Vector2Normalize(*this); + inline Vector2 Lerp(const ::Vector2& vector2, float amount) const { + return Vector2Lerp(*this, vector2, amount); } /** - * Calculate two vectors dot product + * Calculate reflected vector to normal */ - inline float DotProduct(const ::Vector2& vector2) const { - return Vector2DotProduct(*this, vector2); + inline Vector2 Reflect(const ::Vector2& normal) const { + return Vector2Reflect(*this, normal); } /** - * Calculate angle from two vectors in X-axis + * Rotate Vector by float in Degrees */ - inline float Angle(const ::Vector2& vector2) const { - return Vector2Angle(*this, vector2); + inline Vector2 Rotate(float degrees) const { + return Vector2Rotate(*this, degrees); } /** - * Calculate distance between two vectors + * Move Vector towards target */ - inline float Distance(const ::Vector2& vector2) const { - return Vector2Distance(*this, vector2); + inline Vector2 MoveTowards(const ::Vector2& target, float maxDistance) const { + return Vector2MoveTowards(*this, target, maxDistance); } /** - * Calculate linear interpolation between two vectors + * Invert the given vector */ - inline Vector2 Lerp(const ::Vector2& vector2, float amount) const { - return Vector2Lerp(*this, vector2, amount); + inline Vector2 Invert() { + return ::Vector2Invert(*this); } /** - * Calculate reflected vector to normal + * Clamp the components of the vector between */ - inline Vector2 Reflect(const ::Vector2& normal) const { - return Vector2Reflect(*this, normal); + inline Vector2 Clamp(::Vector2 min, ::Vector2 max) { + return ::Vector2Clamp(*this, min, max); } /** - * Rotate Vector by float in Degrees + * // Clamp the magnitude of the vector between two min and max values */ - inline Vector2 Rotate(float degrees) const { - return Vector2Rotate(*this, degrees); + inline Vector2 Clamp(float min, float max) { + return ::Vector2ClampValue(*this, min, max); } /** - * Move Vector towards target + * Check whether two given vectors are almost equal */ - inline Vector2 MoveTowards(const ::Vector2& target, float maxDistance) const { - return Vector2MoveTowards(*this, target, maxDistance); + inline int Equals(::Vector2 q) { + return ::Vector2Equals(*this, q); + } + + /** + * Calculate vector length + */ + inline float Length() const { + return Vector2Length(*this); + } + + /** + * Calculate vector square length + */ + inline float LengthSqr() const { + return Vector2LengthSqr(*this); + } + + /** + * Calculate two vectors dot product + */ + inline float DotProduct(const ::Vector2& vector2) const { + return Vector2DotProduct(*this, vector2); + } + + /** + * Calculate distance between two vectors + */ + inline float Distance(const ::Vector2& vector2) const { + return Vector2Distance(*this, vector2); + } + + /** + * Calculate square distance between two vectors + */ + inline float DistanceSqr(::Vector2 v2) { + return ::Vector2DistanceSqr(*this, v2); + } + + /** + * Calculate angle from two vectors in X-axis + */ + inline float Angle(const ::Vector2& vector2) const { + return Vector2Angle(*this, vector2); } /**