29uint16_t
uidiv(uint32_t dividend, uint16_t divider, uint16_t *remainder) {
30 if (dividend == 0 || dividend < divider) {
31 *remainder = (uint16_t) dividend;
36 div_t results = div((
int) dividend, (
int) (uint32_t) divider);
37 *remainder = (uint16_t) results.rem;
38 return (uint16_t) results.quot;
42 uint16_t start_row, uint16_t start_col,
43 uint16_t step_row, uint16_t step_col,
44 uint16_t *out_row, uint16_t *out_col) {
45 *out_row = start_row + in_row * step_row;
46 *out_col = start_col + in_col * step_col;
50 uint16_t start_col, uint16_t step_row, uint16_t step_col,
51 int16_t *out_row, int16_t *out_col) {
52 int16_t d = (int16_t) (in_row - start_row - 1);
57 d = (int16_t)
uidiv((uint16_t) (-d), step_row, &r);
64 d = (int16_t)
uidiv((uint16_t) d, step_row, &r);
68 d = (int16_t) (in_col - start_col - 1);
72 d = (int16_t)
uidiv((uint16_t) (-d), step_col, &r);
79 d = (int16_t)
uidiv((uint16_t) d, step_col, &r);
void pre_in_post_world(uint16_t in_row, uint16_t in_col, uint16_t start_row, uint16_t start_col, uint16_t step_row, uint16_t step_col, int16_t *out_row, int16_t *out_col)
Get the pre's coordinates in the post's coordinate system.
void post_in_pre_world(uint16_t in_row, uint16_t in_col, uint16_t start_row, uint16_t start_col, uint16_t step_row, uint16_t step_col, uint16_t *out_row, uint16_t *out_col)
Get the post's coordinates in the pre's coordinate system.