aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper/kin_polar.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-06-20 15:44:45 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-06-28 10:00:40 -0400
commite5f74a64ed814bec1bdff11a50566d8f40229216 (patch)
tree8d155cd2599601ad652a86dd76932e238723ebeb /klippy/chelper/kin_polar.c
parentd9d94c858ad6c75ff3171fa0cde0140891619ce3 (diff)
downloadkutter-e5f74a64ed814bec1bdff11a50566d8f40229216.tar.gz
kutter-e5f74a64ed814bec1bdff11a50566d8f40229216.tar.xz
kutter-e5f74a64ed814bec1bdff11a50566d8f40229216.zip
polar: Add initial support for multiple bed rotations
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper/kin_polar.c')
-rw-r--r--klippy/chelper/kin_polar.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/klippy/chelper/kin_polar.c b/klippy/chelper/kin_polar.c
index cc1f2eab..d1a00273 100644
--- a/klippy/chelper/kin_polar.c
+++ b/klippy/chelper/kin_polar.c
@@ -1,6 +1,6 @@
// Polar kinematics stepper pulse time generation
//
-// Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
+// Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
@@ -24,8 +24,12 @@ polar_stepper_angle_calc_position(struct stepper_kinematics *sk, struct move *m
{
struct coord c = move_get_coord(m, move_time);
// XXX - handle x==y==0
- // XXX - handle angle wrapping
- return atan2(c.y, c.x);
+ double angle = atan2(c.y, c.x);
+ if (angle - sk->commanded_pos > M_PI)
+ angle -= 2. * M_PI;
+ else if (angle - sk->commanded_pos < -M_PI)
+ angle += 2. * M_PI;
+ return angle;
}
struct stepper_kinematics * __visible