Given two lines on a plane, how to find integer points closest to their intersection?

alt text http://imagebin.ca/img/yhFOHb.png

Diagram

After you find intersection of lines L1:Ax+By=C and L2:ax+by=c i.e. point A(x1,y1).

Define two more lines y = ceil(y1) and y = floor(y1) parallel to X-axis and find their intersection with L1 and L2 i.e. Points B(x2,y2) and C(x3,y3).

Then point you require is D or E whichever is closer to point A. Similar procedure applies to other parts of the plane.

D ( ceil(x2), ceil(y1)  )
E ( ceil(x3), floor(y1) )

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)