feat(math): add CMath::normalize

This commit is contained in:
VDm 2025-06-23 21:15:55 +04:00
parent fd975cb8e8
commit a4fdad5f69

View file

@ -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