Ok, so I totally reworked the math on this and have uploaded the changes here.