Finding a point on the line Suppose I have a line ax+by+c=0 and some points (x1, y1), (x2, y2), (x3, y3), ....(xn, yn). I wanna have a point on the line such that the total distance from every point to this point on the line is minimum. So is there some formulae or tweak or something that can be of help?
Let your point on the line is (x', y') where y' = -(ax'+c)/b.
Then find the distance to all the other points using pythagoras therom.
Ex: sqrtOf((xi-x')^2 + (yi-y')^2).
Get the summation as f(x) = sqrtOf((x0-x')^2 + (y0-y')^2) + sqrtOf((x1-x')^2 + (y1-y')^2) + ...
Find the first derivative f'(x). Then solve f'(x) = 0.
Let your point on the line is (x', y') where y' = -(ax'+c)/b.
Then find the distance to all the other points using pythagoras therom.
Ex: sqrtOf((xi-x')^2 + (yi-y')^2).
Get the summation as f(x) = sqrtOf((x0-x')^2 + (y0-y')^2) + sqrtOf((x1-x')^2 + (y1-y')^2) + ...
Find the first derivative f'(x). Then solve f'(x) = 0.