basic3d module and some fixes in basic2d

Added the basic3d module. Standard 3d maths but still reimplemented
evrywhere.