[Home]History of CodeSnippets/PointToLine

Robo Home | Changes | Preferences | AllPages


Revision 3 . . (edit) March 5, 2006 16:05 EST by 84.94.41.83.cable.012.net.il
Revision 1 . . July 5, 2005 23:10 EST by Jokester
  

Difference (from prior major revision) (minor diff)

Changed: 53c53,59
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

Robo Home | Changes | Preferences | AllPages
Search: