Function to find foot of perpendicular
function foot ( a , b , c , d , x1 , y1 , z1 ) { var k = ( - a * x1 - b * y1 - c * z1 - d ) / ( a * a + b * b + c * c ) ; var x2 = a * k + x1 ; var y2 = b * k + y1 ; var z2 = c * k + z1 ; document . write ( " " + x2 . toFixed ( 1 ) + " " ) ; document . write ( " " + y2 . toFixed ( 1 ) + " " ) ; document . write ( " " + z2 . toFixed ( 1 ) + " " ) ; }