Foundations for 3D Machine Knitting