line formulas . point on a line with slope of 0

Started by
2 comments, last by Phillipe 19 years, 2 months ago
ok, to find if a point is on a line with a slope, i just plug the point into this formula: y - y1 = m (x - x1) what if the slope is 0??? also , if the point is not on the line, or is across the line, what value will be returned?
I currently only use c# and directX9, in case its relivant and i didnt mention it in the post
Advertisement
If your line has a slope of 0, it means it is parallel to the x-axis.

So if y matches y1, the point is on the line, no matter what x is.

y - y1 - m * (x - x1) = r

If r is zero, the point is on the line, otherwise it is not.


Edit:

You may choose to write your line equation in vector form.

If you have a normal vector n perpendicular to the line, then you can calculate

<n, x-p> = s

where <.,.> is the dot product, p a point on the line and x the point to test.


If s = 0, then x is on the line.

You can obtain n from m as:

n = (-m, +1/m)

if the slope is 0 then you just compare y values.

if y = y1 then the point is on the line

As AP mentioned, just compare the y values, if the state is true (that is, if the values are equal to eachother) then the point is on the line, else - it is not.

This topic is closed to new replies.

Advertisement