The normalize function in Windows::Foundation::Numerics does not work correctly with very small numbers. It returns infinity in both terms of the vector. I corrected the issue like this:
Code:
//=============================================================================
// Normalize the vector.
//=============================================================================
inline void Normalize(Vec2 &v)
{
if (std::abs(v.x) <= EPSILON) // Set very small numbers to 0 to avoid
v.x = 0; // problems with Numerics::normalize().
if (std::abs(v.y) <= EPSILON)
v.y = 0;
v = Windows::Foundation::Numerics::normalize(v);
// If normalize function returns NaN (Not a Number) for X or Y
// component in vector.
if (v.x != v.x) // If v.x is Nan
v.x = 0; // Force to 0
if (v.y != v.y) // If v.y is Nan
v.y = 0; // Force to 0
}