Kevin O'Connor 4dbe795ac2 trapq: Implement sentinel nodes on the trapq list
Use sentinels to make list traversal code simpler.  Also add in null
moves so that there are no time gaps in the list.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-21 13:17:45 -05:00

37 lines
1.0 KiB
C

#ifndef TRAPQ_H
#define TRAPQ_H
#include "list.h" // list_node
struct coord {
double x, y, z;
};
struct move {
double print_time, move_t;
double start_v, half_accel;
struct coord start_pos, axes_r;
struct list_node node;
};
struct trapq {
struct list_head moves;
};
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_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);
struct trapq *trapq_alloc(void);
void trapq_free(struct trapq *tq);
void trapq_check_sentinels(struct trapq *tq);
void trapq_add_move(struct trapq *tq, struct move *m);
void trapq_free_moves(struct trapq *tq, double print_time);
#endif // trapq.h