Browse Source

using GFX_PI internally to avoid issues with M_PI

remotes/origin_old/ugfx_release_2.6
Joel Bodenmann 7 years ago
parent
commit
02e793e5db
  1. 4
      demos/modules/gwin/graph/main.c
  2. 8
      src/gdisp/gdisp.c
  3. 6
      src/gmisc/gmisc.h
  4. 2
      src/gmisc/gmisc_matrix2d.c

4
demos/modules/gwin/graph/main.c

@ -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);

8
src/gdisp/gdisp.c

@ -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;

6
src/gmisc/gmisc.h

@ -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. */

2
src/gmisc/gmisc_matrix2d.c

@ -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

Loading…
Cancel
Save