When I compile the code below, I got these error messages:
(Error 1 error C2065: \'M_PI\' : undeclared identifier 2 IntelliSense: identifier \"M_PI\"
It sounds like you're using MS stuff, according to their docs
Math Constants are not defined in Standard C/C++. To use them, you must first define _USE_MATH_DEFINES and then include cmath or math.h.
So you need something like
#define _USE_MATH_DEFINES #include
as a header.