I give up on Normalization

Compiler was complaining about casting between Vector4 and Matrix<4,1> so I just did the division by hand.

I bet operator* and operator/ are broken for Vector4s as well...
This commit is contained in:
Eryn Wells 2014-08-09 08:31:25 -07:00
parent 32292a45fa
commit cf57dfc51a

View file

@ -64,7 +64,7 @@ Vector4::Z()
/* /*
* charles::basics::Vector4::length2 -- * charles::basics::Vector4::Length2 --
*/ */
Double Double
Vector4::Length2() Vector4::Length2()
@ -74,6 +74,9 @@ Vector4::Length2()
} }
/*
* charles::basics::Vector4::Length --
*/
Double Double
Vector4::Length() Vector4::Length()
const const
@ -82,6 +85,9 @@ Vector4::Length()
} }
/*
* charles::basics::Vector4::Dot --
*/
Double Double
Vector4::Dot(const Vector4& rhs) Vector4::Dot(const Vector4& rhs)
const const
@ -90,6 +96,9 @@ Vector4::Dot(const Vector4& rhs)
} }
/*
* charles::basics::Vector4::Cross --
*/
Vector4 Vector4
Vector4::Cross(const Vector4& rhs) Vector4::Cross(const Vector4& rhs)
const const
@ -100,10 +109,18 @@ Vector4::Cross(const Vector4& rhs)
} }
/*
* charles::basics::Vector4::Normalize --
*/
Vector4& Vector4&
Vector4::Normalize() Vector4::Normalize()
{ {
return *this /= Length(); /* XXX: Is there some way to do this with the Matrix<>::operator/? */
const Double len = Length();
X() = X() / len;
Y() = Y() / len;
Z() = Z() / len;
return *this;
} }
} /* namespace basics */ } /* namespace basics */