Add normalization function to vectors

This commit is contained in:
Pavel Krajcevski 2014-02-16 12:30:37 -05:00
parent e20d84b1ee
commit 543185fe2a

View file

@ -85,6 +85,13 @@ namespace FasTC {
T LengthSq() const { return this->Dot(*this); }
T Length() const { return sqrt(LengthSq()); }
void Normalize() {
T len = Length();
for(int i = 0; i < N; i++) {
vec[i] /= len;
}
}
};
// Operators