Drawing a picture with several points is helpful. For each point, find out the line determined by itself and every other point. Usually a line a determined by k and b, such that y = kx+b. Here, because one point is fixed, each line can be determined by k, which is (p2.y – p1.y) / (p2.x – p1.x), which is a double type number. So to remember all the lines for each one of the point, we can either use k (the double type) as the key, or use two integers p2.y – p1.y and p2.x – p1.x, and divide both numbers by their greatest common divisor.

### Like this:

Like Loading...