aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-11-06 08:41:50 -0500
committerKevin O'Connor <kevin@koconnor.net>2019-11-06 15:51:51 -0500
commit86121ff79ef730a0a7a4d2d35f40cc01f7e1b9e7 (patch)
tree0bd56060e88f145b419b48b4aeeaf8ca5e6c1151 /klippy/chelper
parent257058981eff9b0944029c101de5f18af2fbf914 (diff)
downloadkutter-86121ff79ef730a0a7a4d2d35f40cc01f7e1b9e7.tar.gz
kutter-86121ff79ef730a0a7a4d2d35f40cc01f7e1b9e7.tar.xz
kutter-86121ff79ef730a0a7a4d2d35f40cc01f7e1b9e7.zip
toolhead: Calculate and store axes_r in move class
Calculate the ratio of axis distance to total move distance (axis_d / move_d) and store in a new member variable axes_r. This avoids needing to recalculate the value in other code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper')
-rw-r--r--klippy/chelper/__init__.py2
-rw-r--r--klippy/chelper/trapq.c14
-rw-r--r--klippy/chelper/trapq.h2
3 files changed, 5 insertions, 13 deletions
diff --git a/klippy/chelper/__init__.py b/klippy/chelper/__init__.py
index afd4d922..22649f72 100644
--- a/klippy/chelper/__init__.py
+++ b/klippy/chelper/__init__.py
@@ -61,7 +61,7 @@ defs_trapq = """
void trapq_append(struct trapq *tq, double print_time
, double accel_t, double cruise_t, double decel_t
, double start_pos_x, double start_pos_y, double start_pos_z
- , double axes_d_x, double axes_d_y, double axes_d_z
+ , double axes_r_x, double axes_r_y, double axes_r_z
, double start_v, double cruise_v, double accel);
struct trapq *trapq_alloc(void);
void trapq_free(struct trapq *tq);
diff --git a/klippy/chelper/trapq.c b/klippy/chelper/trapq.c
index 851a15b7..4c2356ad 100644
--- a/klippy/chelper/trapq.c
+++ b/klippy/chelper/trapq.c
@@ -25,19 +25,11 @@ void __visible
trapq_append(struct trapq *tq, double print_time
, double accel_t, double cruise_t, double decel_t
, double start_pos_x, double start_pos_y, double start_pos_z
- , double axes_d_x, double axes_d_y, double axes_d_z
+ , double axes_r_x, double axes_r_y, double axes_r_z
, double start_v, double cruise_v, double accel)
{
- struct coord axes_r, start_pos;
- double inv_move_d = 1. / sqrt(axes_d_x*axes_d_x + axes_d_y*axes_d_y
- + axes_d_z*axes_d_z);
- axes_r.x = axes_d_x * inv_move_d;
- axes_r.y = axes_d_y * inv_move_d;
- axes_r.z = axes_d_z * inv_move_d;
- start_pos.x = start_pos_x;
- start_pos.y = start_pos_y;
- start_pos.z = start_pos_z;
-
+ struct coord start_pos = { x: start_pos_x, y: start_pos_y, z: start_pos_z };
+ struct coord axes_r = { x: axes_r_x, y: axes_r_y, z: axes_r_z };
if (accel_t) {
struct move *m = move_alloc();
m->print_time = print_time;
diff --git a/klippy/chelper/trapq.h b/klippy/chelper/trapq.h
index 787d83a4..ec762621 100644
--- a/klippy/chelper/trapq.h
+++ b/klippy/chelper/trapq.h
@@ -23,7 +23,7 @@ struct move *move_alloc(void);
void trapq_append(struct trapq *tq, double print_time
, double accel_t, double cruise_t, double decel_t
, double start_pos_x, double start_pos_y, double start_pos_z
- , double axes_d_x, double axes_d_y, double axes_d_z
+ , double axes_r_x, double axes_r_y, double axes_r_z
, double start_v, double cruise_v, double accel);
double move_get_distance(struct move *m, double move_time);
struct coord move_get_coord(struct move *m, double move_time);