I will enable the user to draw the polygon. If the user changes the slope of the line to the opposite direction or makes it horizontal, will I need to modify the equations or does it work in all cases?
done .. thank you
I needed to review some forgotten mathematics laws
The equation of a straight line is y=mx+c m is the gradient and c is the height at which the line crosses the y-axis, also known as the y
The gradient m
is the slope of the line - the amount by which the y-coordinate increases in proportion to the x-coordinate. If you have two points (x1,y1) and (x2,y2) on the line, the gradient is
If you know one point (x1,y1) on the line as well as its gradient m, the equation of the line is (y−y1)=m(x−x1)
If we are just given two points (x1,y1)
and (x2,y2), we must first work out the gradient using the gradient formula above, and then choose either point to substitute into the straight line equation with this gradient.