mirror of
https://github.com/yuzu-emu/FasTC
synced 2024-11-22 11:13:59 +00:00
Add normalization function to vectors
This commit is contained in:
parent
e20d84b1ee
commit
543185fe2a
1 changed files with 7 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue