From 51447980c54eab163773b80211a73dbfb3636e79 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Thu, 26 May 2022 12:31:32 -0700 Subject: move coord conversion to board code --- comp.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'comp.c') diff --git a/comp.c b/comp.c index 6b4ec26..3ce0c5e 100644 --- a/comp.c +++ b/comp.c @@ -70,28 +70,16 @@ static double gauss(double mean, double stdev) return mean + (curr * stdev); } -static struct ccoords get_offset() +static struct ccoords gauss_offset() { return (struct ccoords){ .x = gauss(0, horizontal_stdev), .y = gauss(0, vertical_stdev) }; } -struct ccoords pol_to_cart(struct pcoords c) -{ - double t = c.a * (M_PI / 180); - return (struct ccoords){ .x = c.r * cos(t), .y = c.r * sin(t) }; -} - -static struct pcoords cart_to_pol(struct ccoords c) -{ - return (struct pcoords){ .a = atan2(c.y, c.x) * (180 / M_PI), - .r = sqrt(pow(c.x, 2) + pow(c.y, 2)) }; -} - static struct pcoords throw_dart(struct pcoords target, struct ccoords *cc) { struct ccoords tc = pol_to_cart(target); - struct ccoords offset = get_offset(); + struct ccoords offset = gauss_offset(); cc->x = tc.x + offset.x; cc->y = tc.y + offset.y; -- cgit v1.2.3-70-g09d2