# Math Help - Finding if a point lies on a line between 2 others

1. ## Finding if a point lies on a line between 2 others

3 points (a,b) (c,d) and (e,f)
I need to know if point (e,f) lies on the line passing through (a,b) and (c,d)
I know that is the slope of all the lines is the same then they all lie on the same point... but I'm doing that and it's not working!

Take the line through (a,b) and (c,d) and draw a line perpendicular to it at point (a,b).

Now find if point (e,f) lies on the same side of the perpendicular line as (c,d) or not!

These are both for a PC program I'm writing, and my maths really isn't up to scratch! I'm getting a headache and could really do with some help! Please bear in mind, the answer needs to be "zero proof", as in, the computer can't devide by zero, so it needs to avoid that...
any help muchly appreciated!

2. Originally Posted by peanutbutterfingers
3 points (a,b) (c,d) and (e,f)
I need to know if point (e,f) lies on the line passing through (a,b) and (c,d)
I know that is the slope of all the lines is the same then they all lie on the same point... but I'm doing that and it's not working!

...
Take the points P(a, b) and Q(c, d) to determine the equation of the line PQ. Use the 2-point-formula of a straight line:

$PQ: \dfrac{y-b}{x-a}=\dfrac{d-b}{c-a}$

Now plug in the coordinates of point R(e, f) instead of x and y. If the equation becomes true then the 3 points lie on a line:

$\dfrac{f-b}{e-a}=\dfrac{d-b}{c-a}$

3. Originally Posted by peanutbutterfingers
...

These are both for a PC program I'm writing, and my maths really isn't up to scratch! I'm getting a headache and could really do with some help! Please bear in mind, the answer needs to be "zero proof", as in, the computer can't devide by zero, so it needs to avoid that...
any help muchly appreciated!
To avoid the division by zero you have to prove if

i) a = c = e. Then the 3 points are lying on a line perpendicular to the x-axis;

ii) b = d = f. Then the 3 points are lying on a line perpendicular to the y-axis.

A simple if - then - else will do.