Ways:
1.
On some platforms you might need to
#define _USE_MATH_DEFINESand then
M_PIis your friend. Check for more. Taken from my math. h:
/* Define _USE_MATH_DEFINES before including math.h to expose these macro
* definitions for common math constants. These are placed under an #ifdef
* since these commonly-defined names are not part of the C/C++ standards.
*/
2.
Pi can be calculated as atan(1)*4. You could calculate the value this way and cache it
3.
const double pi = boost::math::constants::pi<double>();
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.