Added include <algorithm>
Added type in std::min/std::max
Added include <math.h> and _USE_MATH_DEFINES if WIN32