Implementation

SVG images are built using the following shapes (all of these are subject of an arbitrary affine transformation):

lines

circles

ellipses

elliptic arcs with optional x axis rotation

quadratic and cubic bezier curves

In contrast G-Code implements only

lines

non-elliptical arcs

That means that only lines, circles and some arcs (non-elliptic ones without rotation) can be transleted to G-Code directly. If transformations are also counted, then
only lines can be translated to G-Code directly as circles are not invariant under affine transformations. Because of this, the converter is implemented in two stages.

Stage 1

All the SVG drawing operations are translated to a list of MoveTo, LineTo and CubicBezierTo operations as these are invariant under affine transformations.
Arcs, circles and ellipses can be easily approximated with bezier curves with a small error.

Stage 2

Cubic bezier curves are approximated with Biarcs using the algorithm described in [1] and explained here.