1
0
Fork 0

Spectre/Math: rename all vector length() and normalize() functions to len() and normal()

This commit is contained in:
Henrik Hautakoski 2023-04-30 23:07:25 +02:00
parent 4a6a20342d
commit 43354fc9b4
7 changed files with 17 additions and 17 deletions

View file

@ -30,9 +30,9 @@ struct Vector2
// Named operations.
// -----------------
inline float length() const;
inline float len() const;
inline Vector2<T>& normalize();
inline Vector2<T>& normal();
// Dot product
inline T dot(const Vector2<T>& vec) const;

View file

@ -31,15 +31,15 @@ inline Vector2<T>::Vector2(const Vector2<U>& vec)
}
template <typename T>
inline float Vector2<T>::length() const
inline float Vector2<T>::len() const
{
return std::sqrt((x * x) + (y * y));
}
template <typename T>
inline Vector2<T>& Vector2<T>::normalize()
inline Vector2<T>& Vector2<T>::normal()
{
float il = 1.0f / length();
float il = 1.0f / len();
x *= il; y *= il;
return *this;
}

View file

@ -35,9 +35,9 @@ struct Vector3
// Named operations.
// -----------------
inline float length() const;
inline float len() const;
inline Vector3<T>& normalize();
inline Vector3<T>& normal();
inline Vector2<T> toVec2();
};

View file

@ -43,7 +43,7 @@ inline Vector3<T>::Vector3(const Vector2<U>& vec)
}
template <typename T>
inline float Vector3<T>::length() const
inline float Vector3<T>::len() const
{
return std::sqrt((x * x) + (y * y) + (z * z));
}
@ -55,9 +55,9 @@ Vector2<T> Vector3<T>::toVec2()
}
template <typename T>
inline Vector3<T>& Vector3<T>::normalize()
inline Vector3<T>& Vector3<T>::normal()
{
float il = 1.0f / length();
float il = 1.0f / len();
x *= il; y *= il; z *= il;
return *this;
}

View file

@ -29,9 +29,9 @@ struct Vector4
// Named operations
inline float length() const;
inline float len() const;
inline Vector4<T>& normalize();
inline Vector4<T>& normal();
};
// ---------

View file

@ -36,15 +36,15 @@ Vector4<T>::Vector4(const Vector4<U>& vec)
}
template <typename T>
float Vector4<T>::length() const
float Vector4<T>::len() const
{
return std::sqrt((x * x) + (y * y) + (z * z) + (w * w));
}
template <typename T>
Vector4<T>& Vector4<T>::normalize()
Vector4<T>& Vector4<T>::normal()
{
float il = 1.0f / length();
float il = 1.0f / len();
x *= il; y *= il; z *= il; w *= il;
return *this;
}

View file

@ -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)