using GFX_PI internally to avoid issues with M_PI

This commit is contained in:
Joel Bodenmann 2015-11-28 23:41:24 +01:00
parent 5a99092b79
commit 02e793e5db
4 changed files with 10 additions and 10 deletions

View File

@ -82,14 +82,14 @@ int main(void) {
gwinGraphDrawAxis(gh);
for(i = 0; i < gwinGetWidth(gh); i++)
gwinGraphDrawPoint(gh, i-gwinGetWidth(gh)/2, 80*fsin(2*i/5)); //sin(2*0.2*M_PI*i/180));
gwinGraphDrawPoint(gh, i-gwinGetWidth(gh)/2, 80*fsin(2*i/5)); //sin(2*0.2*GFX_PI*i/180));
gwinGraphStartSet(gh);
GraphStyle1.point.color = Green;
gwinGraphSetStyle(gh, &GraphStyle1);
for(i = 0; i < gwinGetWidth(gh)*5; i++)
gwinGraphDrawPoint(gh, i/5-gwinGetWidth(gh)/2, 95*fsin(2*i/5)); //sin(2*0.2*M_PI*i/180));
gwinGraphDrawPoint(gh, i/5-gwinGetWidth(gh)/2, 95*fsin(2*i/5)); //sin(2*0.2*GFX_PI*i/180));
gwinGraphStartSet(gh);
gwinGraphSetStyle(gh, &GraphStyle2);

View File

@ -1725,8 +1725,8 @@ void gdispGBlitArea(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, c
sedge = round(radius * ((sbit & 0x99) ? fsin(start) : fcos(start)));
eedge = round(radius * ((ebit & 0x99) ? fsin(end) : fcos(end)));
#else
sedge = round(radius * ((sbit & 0x99) ? sin(start*M_PI/180) : cos(start*M_PI/180)));
eedge = round(radius * ((ebit & 0x99) ? sin(end*M_PI/180) : cos(end*M_PI/180)));
sedge = round(radius * ((sbit & 0x99) ? sin(start*GFX_PI/180) : cos(start*GFX_PI/180)));
eedge = round(radius * ((ebit & 0x99) ? sin(end*GFX_PI/180) : cos(end*GFX_PI/180)));
#endif
if (sbit & 0xB4) sedge = -sedge;
if (ebit & 0xB4) eedge = -eedge;
@ -1852,8 +1852,8 @@ void gdispGBlitArea(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, c
sxb = FP2FIXED(radius*fcos(start)); sy = -round(radius*fsin(start));
exb = FP2FIXED(radius*fcos(end)); ey = -round(radius*fsin(end));
#else
sxb = FP2FIXED(radius*cos(start*M_PI/180)); sy = -round(radius*sin(start*M_PI/180));
exb = FP2FIXED(radius*cos(end*M_PI/180)); ey = -round(radius*sin(end*M_PI/180));
sxb = FP2FIXED(radius*cos(start*GFX_PI/180)); sy = -round(radius*sin(start*GFX_PI/180));
exb = FP2FIXED(radius*cos(end*GFX_PI/180)); ey = -round(radius*sin(end*GFX_PI/180));
#endif
sxd = sy ? sxb/sy : sxb;
exd = ey ? exb/ey : exb;

View File

@ -75,14 +75,14 @@ typedef int32_t fixed;
/**
* @brief The famous number pi
*/
#ifndef PI
#define PI 3.1415926535897932384626433832795028841971693993751
#ifndef GFX_PI
#define GFX_PI 3.1415926535897932384626433832795028841971693993751
#endif
/**
* @brief pi as a fixed point
*/
#define FIXED_PI FP2FIXED(PI)
#define FIXED_PI FP2FIXED(GFX_PI)
/*===========================================================================*/
/* External declarations. */

View File

@ -75,7 +75,7 @@ void gmiscMatrixFloat2DApplyRotation(MatrixFloat2D *dst, const MatrixFloat2D *sr
s = fsin(angle);
c = fcos(angle);
#else
c = angle*M_PI/180;
c = angle*GFX_PI/180;
s = sin(c);
c = cos(c);
#endif