forked from Mirrors/openclonk
Use <cmath> M_PI instead of own "pi" constant
This solves a conflict with a definition with the same name within Apple SDK headers (thanks, Mortimer)
parent
9d672997bf
commit
46ece7030e
|
@ -24,6 +24,11 @@
|
|||
#ifndef INC_C4Include
|
||||
#define INC_C4Include
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Get non-standard <cmath> constants (M_PI etc.)
|
||||
# define _USE_MATH_DEFINES
|
||||
#endif
|
||||
|
||||
#include "PlatformAbstraction.h"
|
||||
#include "Standard.h"
|
||||
#include "C4Prototypes.h"
|
||||
|
@ -54,6 +59,7 @@
|
|||
#include <cctype>
|
||||
#include <cerrno>
|
||||
#include <climits>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdarg>
|
||||
#include <cstddef>
|
||||
|
|
|
@ -86,7 +86,7 @@ void C4MapCreator::Create(CSurface8 *sfcMap,
|
|||
C4SLandscape &rLScape, C4TextureMap &rTexMap,
|
||||
bool fLayers, int32_t iPlayerNum)
|
||||
{
|
||||
double fullperiod= 20.0 * pi;
|
||||
double fullperiod= 20.0 * M_PI;
|
||||
BYTE ccol;
|
||||
int32_t cx,cy;
|
||||
|
||||
|
@ -128,7 +128,7 @@ void C4MapCreator::Create(CSurface8 *sfcMap,
|
|||
|
||||
cy_natural=rnd_cy*natural/100.0;
|
||||
cy_curve=sin(fullperiod*period/100.0*(float)cx/(float)MapWdt
|
||||
+2.0*pi*phase/100.0) * amplitude/100.0;
|
||||
+2.0*M_PI*phase/100.0) * amplitude/100.0;
|
||||
|
||||
cy=level0+BoundBy((int32_t)((float)maxrange*(cy_curve+cy_natural)),
|
||||
-maxrange,+maxrange);
|
||||
|
|
|
@ -698,8 +698,8 @@ int32_t FnFxFireTimer(C4AulContext *ctx, C4Object *pObj, int32_t iNumber, int32_
|
|||
float fRot[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||
if (pObj->r && pObj->Def->Rotateable)
|
||||
{
|
||||
fRot[0] = (float) cosf((float) (pObj->r * pi/180.0));
|
||||
fRot[1] = (float) -sinf((float) (pObj->r * pi/180.0));
|
||||
fRot[0] = (float) cosf((float) (pObj->r * M_PI/180.0));
|
||||
fRot[1] = (float) -sinf((float) (pObj->r * M_PI/180.0));
|
||||
fRot[2] = -fRot[1];
|
||||
fRot[3] = fRot[0];
|
||||
// rotated objects usually better burn from the center
|
||||
|
|
|
@ -2977,7 +2977,7 @@ static long FnAngle(C4AulContext *cthr, long iX1, long iY1, long iX2, long iY2,
|
|||
else return 270 * iPrec;
|
||||
}
|
||||
|
||||
iAngle = static_cast<long>(180.0 * iPrec * atan2(static_cast<double>(Abs(dy)), static_cast<double>(Abs(dx))) / pi);
|
||||
iAngle = static_cast<long>(180.0 * iPrec * atan2(static_cast<double>(Abs(dy)), static_cast<double>(Abs(dx))) / M_PI);
|
||||
|
||||
if (iX2>iX1 )
|
||||
{
|
||||
|
@ -3000,7 +3000,7 @@ static long FnArcSin(C4AulContext *cthr, long iVal, long iRadius)
|
|||
if (iVal > iRadius) return 0;
|
||||
// calc arcsin
|
||||
double f1 = iVal;
|
||||
f1 = asin(f1/iRadius)*180.0/pi;
|
||||
f1 = asin(f1/iRadius)*180.0/M_PI;
|
||||
// return rounded angle
|
||||
return (long) floor(f1+0.5);
|
||||
}
|
||||
|
@ -3012,7 +3012,7 @@ static long FnArcCos(C4AulContext *cthr, long iVal, long iRadius)
|
|||
if (iVal > iRadius) return 0;
|
||||
// calc arccos
|
||||
double f1 = iVal;
|
||||
f1 = acos(f1/iRadius)*180.0/pi;
|
||||
f1 = acos(f1/iRadius)*180.0/M_PI;
|
||||
// return rounded angle
|
||||
return (long) floor(f1+0.5);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "C4Include.h"
|
||||
#include <StdSync.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <sys/timeb.h>
|
||||
|
||||
//------------------------------------- Basics ----------------------------------------
|
||||
|
@ -42,7 +41,7 @@ int32_t Distance(int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2)
|
|||
|
||||
int Angle(int iX1, int iY1, int iX2, int iY2)
|
||||
{
|
||||
int iAngle = (int) ( 180.0 * atan2( float(Abs(iY1-iY2)), float(Abs(iX1-iX2)) ) / pi );
|
||||
int iAngle = (int) ( 180.0 * atan2( float(Abs(iY1-iY2)), float(Abs(iX1-iX2)) ) / M_PI );
|
||||
if (iX2>iX1 )
|
||||
{ if (iY2<iY1) iAngle = 90-iAngle; else iAngle = 90+iAngle; }
|
||||
else
|
||||
|
|
|
@ -40,8 +40,6 @@ template <class T> inline int Sign(T val) { return val < 0 ? -1 : val > 0 ? 1 :
|
|||
template <class T> inline void Swap(T &v1, T &v2) { T t = v1; v1 = v2; v2 = t; }
|
||||
template <class T> inline void Toggle(T &v) { v = !v; }
|
||||
|
||||
const double pi = 3.14159265358979323846;
|
||||
|
||||
inline int DWordAligned(int val)
|
||||
{
|
||||
if (val%4) { val>>=2; val<<=2; val+=4; }
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "StdMesh.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
// Global access pointer
|
||||
|
@ -819,7 +818,7 @@ bool CStdDDraw::BlitRotate(SURFACE sfcSource, int fx, int fy, int fwdt, int fhgt
|
|||
|
||||
default:
|
||||
// Calculate rotation matrix
|
||||
dang=pi*iAngle/18000.0;
|
||||
dang=M_PI*iAngle/18000.0;
|
||||
mtx[0]=cos(dang); mtx[1]=-sin(dang);
|
||||
mtx[2]=sin(dang); mtx[3]= cos(dang);
|
||||
// Blit source rect
|
||||
|
|
|
@ -33,7 +33,6 @@ static uint32_t dwStdGamepadMinY = 0;
|
|||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <math.h>
|
||||
|
||||
uint32_t POV2Position(DWORD dwPOV, bool fVertical)
|
||||
{
|
||||
|
@ -44,7 +43,7 @@ uint32_t POV2Position(DWORD dwPOV, bool fVertical)
|
|||
dAxis = 0.0;
|
||||
// Angle: convert to linear value -100 to +100
|
||||
else
|
||||
dAxis = (fVertical ? -cos((dwPOV/100) * pi / 180.0) : sin((dwPOV/100) * pi / 180.0)) * 100.0;
|
||||
dAxis = (fVertical ? -cos((dwPOV/100) * M_PI / 180.0) : sin((dwPOV/100) * M_PI / 180.0)) * 100.0;
|
||||
// Gamepad configuration wants unsigned and gets 0 to 200
|
||||
return (uint32_t) (dAxis + 100.0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue