summaryrefslogtreecommitdiff
path: root/include/mupdf/fitz/system.h
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2017-05-28 19:23:02 +0800
committerSebastian Rasmussen <sebras@gmail.com>2017-05-29 18:15:40 +0800
commit154efc3e429508bf27dbd31ebe66b6e1a26b7ded (patch)
tree6c02cc820dd732c0efc44fe401997b39b645bd11 /include/mupdf/fitz/system.h
parent2f987ef9812f74be9c272563d200e8ef1bac46ea (diff)
downloadmupdf-154efc3e429508bf27dbd31ebe66b6e1a26b7ded.tar.xz
Make PI/RADIAN/SQRT2/LN2 global single precision float constants.
Diffstat (limited to 'include/mupdf/fitz/system.h')
-rw-r--r--include/mupdf/fitz/system.h38
1 files changed, 18 insertions, 20 deletions
diff --git a/include/mupdf/fitz/system.h b/include/mupdf/fitz/system.h
index a5cd8922..26d03e2c 100644
--- a/include/mupdf/fitz/system.h
+++ b/include/mupdf/fitz/system.h
@@ -48,13 +48,11 @@
#define nelem(x) (sizeof(x)/sizeof((x)[0]))
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-#ifndef M_SQRT2
-#define M_SQRT2 1.41421356237309504880
-#endif
+#define FZ_PI 3.14159265f
+#define FZ_RADIAN 57.2957795f
+#define FZ_DEGREE 0.017453292f
+#define FZ_SQRT2 1.41421356f
+#define FZ_LN2 0.69314718f
/*
Spot architectures where we have optimisations.
@@ -411,19 +409,19 @@ static inline float my_sinf(float x)
float x2, xn;
int i;
/* Map x into the -PI to PI range. We could do this using:
- * x = fmodf(x, (float)(2.0 * M_PI));
+ * x = fmodf(x, (float)(2.0 * FZ_PI));
* but that's C99, and seems to misbehave with negative numbers
* on some platforms. */
- x -= (float)M_PI;
- i = x / (float)(2.0f * M_PI);
- x -= i * (float)(2.0f * M_PI);
+ x -= FZ_PI;
+ i = x / (float)(2.0f * FZ_PI);
+ x -= i * (float)(2.0f * FZ_PI);
if (x < 0.0f)
- x += (float)(2.0f * M_PI);
- x -= (float)M_PI;
- if (x <= (float)(-M_PI/2.0))
- x = -(float)M_PI-x;
- else if (x >= (float)(M_PI/2.0))
- x = (float)M_PI-x;
+ x += (float)(2.0f * FZ_PI);
+ x -= FZ_PI;
+ if (x <= (float)(-FZ_PI/2.0))
+ x = -FZ_PI-x;
+ else if (x >= (float)(FZ_PI/2.0))
+ x = FZ_PI-x;
x2 = x*x;
xn = x*x2/6.0f;
x -= xn;
@@ -445,7 +443,7 @@ static inline float my_atan2f(float o, float a)
if (a > 0)
return 0.0f;
else
- return (float)M_PI;
+ return FZ_PI;
}
if (o < 0)
o = -o, negate = 1;
@@ -461,14 +459,14 @@ static inline float my_atan2f(float o, float a)
if (o >= a)
r = (float)(M_PI/2.0f) - r;
if (flip)
- r = (float)M_PI - r;
+ r = FZ_PI - r;
if (negate)
r = -r;
return r;
}
#define sinf(x) my_sinf(x)
-#define cosf(x) my_sinf(((float)(M_PI/2.0f)) + (x))
+#define cosf(x) my_sinf((M_PI / 2.0f) + (x))
#define atan2f(x,y) my_atan2f((x),(y))
#endif