This is a rewrite version (in C) from Horde3D (utMath.h)