line formulas . point on a line with slope of 0
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?
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)
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)
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
Popular Topics
Advertisement