Can somebody please help me out. I need to find a solution for this problem:
I've got to POINTS- A(x1,y1) and B(x2,y2) that make a LINE and a RECTANGLE (left upper corner point C (xmin,ymin) right botom corner point D(xmax,ymax) on a two dimensional graph.
LINE can be drawn everywhere on a graph.
RECTANGLE can be drawn everywhere on a graph.
I need to get Points E and F that are starting point and ending point of line AB in side the RECTANGLE.
in this case A is outside rectangle while B is inside so E becomes (2,2) and F is B
P.S. My biggest pbroblem is that i cant deal with all the possibilities. Im able to check say A to find out if its y is too small and then adjust it using line formua for tangent, but if i do that i end up with 16 different situations for each end of line and i know there must be a easier way. But since i havent done this type of thing in a while it takes me forever.
Really looking forward from hearing you people.