diff options
author | max-001 <maxsmits21@kpnmail.nl> | 2024-12-04 16:50:23 +0100 |
---|---|---|
committer | max-001 <maxsmits21@kpnmail.nl> | 2024-12-04 16:50:23 +0100 |
commit | 94d95cb13e76d6cd3ec892a7f0b2bab938a9ba6a (patch) | |
tree | 19d3d33f6a24dca691be7f349ed6e69eae81142b /src/crepe/api/Vector2.h | |
parent | f9f5600b60d6944dc9a7dd502988703d59d0cd62 (diff) |
Extended Vector2
Diffstat (limited to 'src/crepe/api/Vector2.h')
-rw-r--r-- | src/crepe/api/Vector2.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/crepe/api/Vector2.h b/src/crepe/api/Vector2.h index c278c87..bbcb932 100644 --- a/src/crepe/api/Vector2.h +++ b/src/crepe/api/Vector2.h @@ -66,6 +66,30 @@ struct Vector2 { //! Checks if this vector is not equal to another vector. bool operator!=(const Vector2<T> & other) const; + + //! Truncates the vector to a maximum length. + void truncate(T max); + + //! Normalizes the vector. + void normalize(); + + //! Returns the length of the vector. + T length() const; + + //! Returns the squared length of the vector. + T length_squared() const; + + //! Returns the dot product of this vector and another vector. + T dot(const Vector2<T> & other) const; + + //! Returns the distance between this vector and another vector. + T distance(const Vector2<T> & other) const; + + //! Returns the squared distance between this vector and another vector. + T distance_squared(const Vector2<T> & other) const; + + //! Returns the perpendicular vector to this vector. + Vector2 perpendicular() const; }; } // namespace crepe |