From 570679c333af5d7505d94876d7011664e465dc4b Mon Sep 17 00:00:00 2001 From: epoch Date: Sat, 4 Nov 2017 04:22:32 -0500 Subject: added radians to degrees function --- src/math.c | 4 ++++ src/math.h | 1 + 2 files changed, 5 insertions(+) (limited to 'src') diff --git a/src/math.c b/src/math.c index 82328b7..3993223 100644 --- a/src/math.c +++ b/src/math.c @@ -49,6 +49,10 @@ 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) )); } +degrees r2d(radians r) { + return (degrees){(r.r * (real)180 / M_PIl) }; +} + radians d2r(degrees d) { while(d.d<0) d.d+=360; return (radians){(real)(d.d%360) / (real)180 * M_PIl}; diff --git a/src/math.h b/src/math.h index f369082..40121ea 100644 --- a/src/math.h +++ b/src/math.h @@ -14,6 +14,7 @@ c3_t rotate_c3_yr(c3_t p1,c3_t p2,radians yr); c3_t rotate_c3_zr(c3_t p1,c3_t p2,radians zr); c3_group_rot_t *get_group_rotation(char *id); radians d2r(degrees d); +degrees r2d(radians r); radians points_to_angle(c2_t p1,c2_t p2); #endif -- cgit v1.2.3