From 94d95cb13e76d6cd3ec892a7f0b2bab938a9ba6a Mon Sep 17 00:00:00 2001 From: max-001 Date: Wed, 4 Dec 2024 16:50:23 +0100 Subject: Extended Vector2 --- src/crepe/api/Vector2.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/crepe/api/Vector2.h') 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 & 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 & other) const; + + //! Returns the distance between this vector and another vector. + T distance(const Vector2 & other) const; + + //! Returns the squared distance between this vector and another vector. + T distance_squared(const Vector2 & other) const; + + //! Returns the perpendicular vector to this vector. + Vector2 perpendicular() const; }; } // namespace crepe -- cgit v1.2.3 From 9cd9e3674d8b1c326c81b7896b9254408fb19972 Mon Sep 17 00:00:00 2001 From: max-001 Date: Fri, 6 Dec 2024 08:42:49 +0100 Subject: Added some explanation to Vector2 --- src/crepe/api/Vector2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/crepe/api/Vector2.h') diff --git a/src/crepe/api/Vector2.h b/src/crepe/api/Vector2.h index bbcb932..bf9d124 100644 --- a/src/crepe/api/Vector2.h +++ b/src/crepe/api/Vector2.h @@ -70,7 +70,7 @@ struct Vector2 { //! Truncates the vector to a maximum length. void truncate(T max); - //! Normalizes the vector. + //! Normalizes the vector (resulting in vector with a length of 1). void normalize(); //! Returns the length of the vector. @@ -79,7 +79,7 @@ struct Vector2 { //! Returns the squared length of the vector. T length_squared() const; - //! Returns the dot product of this vector and another vector. + //! Returns the dot product (inwendig product) of this vector and another vector. T dot(const Vector2 & other) const; //! Returns the distance between this vector and another vector. -- cgit v1.2.3