Add Unit for vector2

Former-commit-id: 4a143363f24e08d0be12a5ef6bfb46c71b11be4a
This commit is contained in:
Gawaboumga
2015-08-21 11:34:08 +02:00
parent 376df6a3b7
commit 2d07922478
2 changed files with 21 additions and 6 deletions

View File

@@ -105,6 +105,12 @@ T NzVector2<T>::GetSquaredLength() const
return x*x + y*y;
}
template<typename T>
NzVector2<T>& NzVector2<T>::MakeUnit()
{
return Set(F(1.0), F(1.0));
}
template<typename T>
NzVector2<T>& NzVector2<T>::MakeUnitX()
{
@@ -129,7 +135,7 @@ NzVector2<T>& NzVector2<T>::Maximize(const NzVector2& vec)
if (vec.x > x)
x = vec.x;
if (vec.y > y)
if (vec.y > y)
y = vec.y;
return *this;
@@ -141,7 +147,7 @@ NzVector2<T>& NzVector2<T>::Minimize(const NzVector2& vec)
if (vec.x < x)
x = vec.x;
if (vec.y < y)
if (vec.y < y)
y = vec.y;
return *this;
@@ -229,7 +235,7 @@ NzVector2<T>& NzVector2<T>::Set(const NzVector4<T>& vec)
template<typename T>
T NzVector2<T>::SquaredDistance(const NzVector2& vec) const
{
return operator-(vec).GetSquaredLength();
return (*this - vec).GetSquaredLength();
}
template<typename T>
@@ -398,7 +404,7 @@ template<typename T>
bool NzVector2<T>::operator==(const NzVector2& vec) const
{
return NzNumberEquals(x, vec.x) &&
NzNumberEquals(y, vec.y);
NzNumberEquals(y, vec.y);
}
template<typename T>
@@ -443,6 +449,15 @@ NzVector2<T> NzVector2<T>::Lerp(const NzVector2& from, const NzVector2& to, T in
return NzLerp(from, to, interpolation);
}
template<typename T>
NzVector2<T> NzVector2<T>::Unit()
{
NzVector2 vector;
vector.MakeUnit();
return vector;
}
template<typename T>
NzVector2<T> NzVector2<T>::UnitX()
{