'Takes a start position and a gcode, and returns a 3-uple containing
(final position, line, arc), with line and arc being None if not
used'

def _get_movement(self, start_pos, gline):

    target = start_pos[:]
    target[5] = 0.0
    target[6] = 0.0
    if (gline.current_x is not None):
        target[0] = gline.current_x
    if (gline.current_y is not None):
        target[1] = gline.current_y
    if (gline.current_z is not None):
        target[2] = gline.current_z
    if (gline.e is not None):
        if gline.relative_e:
            target[3] += gline.e
        else:
            target[3] = gline.e
    if (gline.f is not None):
        target[4] = gline.f
    if (gline.i is not None):
        target[5] = gline.i
    if (gline.j is not None):
        target[6] = gline.j
    if (gline.command in ['G0', 'G1']):
        line = [self._x(start_pos[0]), self._y(start_pos[1]), self._x(target[0]), self._y(target[1])]
        return (target, line, None)
    elif (gline.command in ['G2', 'G3']):
        arc = [self._x(start_pos[0]), self._y(start_pos[1]), self._x(target[0]), self._y(target[1]), self._x((start_pos[0] + target[5])), self._y((start_pos[1] + target[6]))]
        if (gline.command == 'G2'):
            (arc[0], arc[1], arc[2], arc[3]) = (arc[2], arc[3], arc[0], arc[1])
        return (target, None, arc)
