I have two x,y
pairs that create a line within a bounding box.
coord1 = 75, 180
coord2 = -30, 300
The bounding box is x0
to x500
and y0
to y400
I want to create an object that can tell me the coordinates of where the line intersects the bounding box.
i.e.
Intercept.new(bounding_box, coord1, coord2).call!
returns the intercept point [x,y]
I believe I need to use y = mx + b
, but I'm having trouble writting an object that can take these two coordinates, factor in the bounding box, and tell me where the intersection point happens. Can anyone take a shot and help me out here?
EDIT Not a duplicate of the question linked in the comments. That question has a constant of the point B always being in the center of the rectangle.