From 43354fc9b4d28ec6914d0f5f8f845c569435ad98 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 30 Apr 2023 23:07:25 +0200 Subject: [PATCH] Spectre/Math: rename all vector length() and normalize() functions to len() and normal() --- include/Spectre/Math/Vector2.h | 4 ++-- include/Spectre/Math/Vector2.inl | 6 +++--- include/Spectre/Math/Vector3.h | 4 ++-- include/Spectre/Math/Vector3.inl | 6 +++--- include/Spectre/Math/Vector4.h | 4 ++-- include/Spectre/Math/Vector4.inl | 6 +++--- source/Math/Transform.cpp | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/Spectre/Math/Vector2.h b/include/Spectre/Math/Vector2.h index 06fd97e..1def70e 100644 --- a/include/Spectre/Math/Vector2.h +++ b/include/Spectre/Math/Vector2.h @@ -30,9 +30,9 @@ struct Vector2 // Named operations. // ----------------- - inline float length() const; + inline float len() const; - inline Vector2& normalize(); + inline Vector2& normal(); // Dot product inline T dot(const Vector2& vec) const; diff --git a/include/Spectre/Math/Vector2.inl b/include/Spectre/Math/Vector2.inl index 241a405..fcc0f6e 100644 --- a/include/Spectre/Math/Vector2.inl +++ b/include/Spectre/Math/Vector2.inl @@ -31,15 +31,15 @@ inline Vector2::Vector2(const Vector2& vec) } template -inline float Vector2::length() const +inline float Vector2::len() const { return std::sqrt((x * x) + (y * y)); } template -inline Vector2& Vector2::normalize() +inline Vector2& Vector2::normal() { - float il = 1.0f / length(); + float il = 1.0f / len(); x *= il; y *= il; return *this; } diff --git a/include/Spectre/Math/Vector3.h b/include/Spectre/Math/Vector3.h index a641fbd..2bf87d4 100644 --- a/include/Spectre/Math/Vector3.h +++ b/include/Spectre/Math/Vector3.h @@ -35,9 +35,9 @@ struct Vector3 // Named operations. // ----------------- - inline float length() const; + inline float len() const; - inline Vector3& normalize(); + inline Vector3& normal(); inline Vector2 toVec2(); }; diff --git a/include/Spectre/Math/Vector3.inl b/include/Spectre/Math/Vector3.inl index 1b1d2a4..bc9496d 100644 --- a/include/Spectre/Math/Vector3.inl +++ b/include/Spectre/Math/Vector3.inl @@ -43,7 +43,7 @@ inline Vector3::Vector3(const Vector2& vec) } template -inline float Vector3::length() const +inline float Vector3::len() const { return std::sqrt((x * x) + (y * y) + (z * z)); } @@ -55,9 +55,9 @@ Vector2 Vector3::toVec2() } template -inline Vector3& Vector3::normalize() +inline Vector3& Vector3::normal() { - float il = 1.0f / length(); + float il = 1.0f / len(); x *= il; y *= il; z *= il; return *this; } diff --git a/include/Spectre/Math/Vector4.h b/include/Spectre/Math/Vector4.h index e73dcf3..622e4b3 100644 --- a/include/Spectre/Math/Vector4.h +++ b/include/Spectre/Math/Vector4.h @@ -29,9 +29,9 @@ struct Vector4 // Named operations - inline float length() const; + inline float len() const; - inline Vector4& normalize(); + inline Vector4& normal(); }; // --------- diff --git a/include/Spectre/Math/Vector4.inl b/include/Spectre/Math/Vector4.inl index c759fb7..e825150 100644 --- a/include/Spectre/Math/Vector4.inl +++ b/include/Spectre/Math/Vector4.inl @@ -36,15 +36,15 @@ Vector4::Vector4(const Vector4& vec) } template -float Vector4::length() const +float Vector4::len() const { return std::sqrt((x * x) + (y * y) + (z * z) + (w * w)); } template -Vector4& Vector4::normalize() +Vector4& Vector4::normal() { - float il = 1.0f / length(); + float il = 1.0f / len(); x *= il; y *= il; z *= il; w *= il; return *this; } diff --git a/source/Math/Transform.cpp b/source/Math/Transform.cpp index 189ef8c..4854eb2 100644 --- a/source/Math/Transform.cpp +++ b/source/Math/Transform.cpp @@ -42,12 +42,12 @@ void Transform::reset() Vector2f Transform::getUpVector() const { - return Vector2f(m_matrix.e[4], m_matrix.e[5]).normalize(); + return Vector2f(m_matrix.e[4], m_matrix.e[5]).normal(); } Vector2f Transform::getRightVector() const { - return Vector2f(m_matrix.e[0], m_matrix.e[1]).normalize(); + return Vector2f(m_matrix.e[0], m_matrix.e[1]).normal(); } Transform& Transform::translate(float x, float y)