if we know the start point and the end point for an line how can you find the all point that line pass it ??
If you mean points with integer coordinates, you find the delta x and delta y between your start and end points and get the greatest common divisor of the two. Then your points are of the form
(startx + N * deltax / gcd(deltay, deltax), starty + N * deltay / gcd(deltay, deltax))
where N ranges from 0 to gcd(deltay, deltax).
say x1,y1 and x2,y2 are points you have then equation of line joining two points will be
y - y1 = (x - x1) * ((y2-y1)/(x2-x1)).
To find every other point substitute x or y and get the other
Based on how long ago you became a member and the type of question you asked, this sounds like a homework question. I help you anyway but I leave something for thing for you to figure out.
- To write a program to do this, you need to know the algebra behind it.
- Equation for a straight line: y = mx + b where m is the slope and b is the y-intersect
- First find the slope, then find the y-intersect.
- Now the tricky part, it's difficult to find ALL points that are on the line. It's however EASY to find all points with either integer x-coordinate or integer y-coordinate that are on the line.
Please go through the URL,
http://cs.unc.edu/~mcmillan/comp136/Lecture6/Lines.html
You will get different type of implementations and select one which is fitting your application.