summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2017-12-24 04:34:11 -0600
committerepoch <epoch@hacking.allowed.org>2017-12-24 04:34:11 -0600
commit37084e19a685cb029fa49a78e4bafe8dd07ab634 (patch)
tree5d9f04ac3f8565569be7dd6708b1a48189b6f7a4 /src
parentb8708f9c58e499db7afc2cb093c454c3b34895aa (diff)
downloadhackvr-37084e19a685cb029fa49a78e4bafe8dd07ab634.tar.gz
hackvr-37084e19a685cb029fa49a78e4bafe8dd07ab634.zip
switching math to just double and not double long
Diffstat (limited to 'src')
-rw-r--r--src/math.c14
-rw-r--r--src/math.h6
2 files changed, 11 insertions, 9 deletions
diff --git a/src/math.c b/src/math.c
index 75ec93c..f9221a3 100644
--- a/src/math.c
+++ b/src/math.c
@@ -43,24 +43,24 @@ c2_t rotate_c2(c2_t p1,c2_t p2,radians dr) {
real d=distance2(p1,p2);
radians r=points_to_angle(p2,p1);
r.r=r.r+dr.r;
- p3.x=(cosl(r.r) * d) + p2.x;
- p3.y=(sinl(r.r) * d) + p2.y;
+ p3.x=(cos(r.r) * d) + p2.x;
+ p3.y=(sin(r.r) * d) + p2.y;
return p3;
}
real distance2(c2_t p1,c2_t p2) {
- return sqrtl(( (p1.x-p2.x)*(p1.x-p2.x) )+( (p1.y-p2.y)*(p1.y-p2.y) ));
+ return sqrt(( (p1.x-p2.x)*(p1.x-p2.x) )+( (p1.y-p2.y)*(p1.y-p2.y) ));
}
degrees r2d(radians r) {
- return (degrees){(r.r * (real)180 / M_PIl) };
+ return (degrees){(r.r * (real)180 / M_PI) };
}
radians d2r(degrees d) {
while(d.d<0) d.d+=360;
- return (radians){(real)(d.d%360) / (real)180 * M_PIl};
+ return (radians){(real)(d.d%360) / (real)180 * M_PI};
}
//the angle from the first point to the second point. not the other way around.
radians points_to_angle(c2_t p1,c2_t p2) {
- real a=atan2l(p2.y-p1.y,p2.x-p1.x);
- return (radians){a>=0?a:M_PIl+M_PIl+a};
+ real a=atan2(p2.y-p1.y,p2.x-p1.x);
+ return (radians){a>=0?a:M_PI+M_PI+a};
}
diff --git a/src/math.h b/src/math.h
index 40121ea..7e65047 100644
--- a/src/math.h
+++ b/src/math.h
@@ -3,9 +3,11 @@
#include "common.h" //should define c3_t
-#define __USE_GNU
#include <math.h>
-#undef __USE_GNU
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
real distance2(c2_t p1,c2_t p2);
c2_t rotate_c2(c2_t p1,c2_t p2,radians dr);