3d math

 ios version
replace tab with space and some code adjustment