ahmed sami

ahmed sami

  • NA
  • 64
  • 198.2k

the distance from a point to a line

Nov 30 2012 6:26 AM
Write a function to calculate the distance from a point to a line. The formula describing the line is: Ax + By + C = 0. If the coordinates of the point P are ( 0 x , 0 y ), the distance d from the point P to the line can be calculated by:

(the rar file)

The function calculates and returns the distance from (x0, y0) to the line described by coefficients A, B and C.

Example:
The distance from (-2, 1.5) to the line described by 2x + 3.5y - 4 = 0 is found by:
dist = distance(2, 3.5, -4, -2, 1.5);


Attachment: untitled.rar

Answers (1)