This code hasn't been tested, but the formulas are correct to the best of my ability and I double checked them. I hope this helps. (Added 16:35 GMT-6 April 13, 2005) -- troutinator |
This code hasn't been tested, but the formulas are correct to the best of my ability and I double checked them. I hope this helps. (Added 16:35 GMT-6 April 13, 2005) -- troutinator slope = ( (line.getY2() - line.getY()) / (line.getX2() - line.getX()) ); or perpendicular_slope = -(1/slope); can return a runtime error because if line.getX2() - line.getX() equals to 0 or if the slope is calculated to be 0 (line.getY2() - line.getY() equals to zero). in which case, you'd might want to use exception handling and catch those two division by zero exceptions, on the first one, set perpendicular_slope to be 0, and in the other, set it to be POSITIVE_INFINITY. -- Avihoo Ilan |