mirror of
https://github.com/thunderbrewhq/typhoon.git
synced 2025-12-12 02:22:30 +00:00
feat(math): add CMath::normalize
This commit is contained in:
parent
fd975cb8e8
commit
a4fdad5f69
1 changed files with 17 additions and 0 deletions
|
|
@ -61,6 +61,23 @@ class CMath {
|
|||
STORM_ASSERT(x >= 0.0f);
|
||||
return ::sqrt(x);
|
||||
}
|
||||
|
||||
static void normalize(float& x, float& y) {
|
||||
float m = x * x + y * y;
|
||||
STORM_ASSERT(m >= 0.0f);
|
||||
m = 1.0f / CMath::sqrt(m);
|
||||
x *= m;
|
||||
y *= m;
|
||||
}
|
||||
|
||||
static void normalize(float& x, float& y, float& z) {
|
||||
float m = x * x + y * y + z * z;
|
||||
STORM_ASSERT(m >= 0.0f);
|
||||
m = 1.0f / CMath::sqrt(m);
|
||||
x *= m;
|
||||
y *= m;
|
||||
z *= m;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue