I have one simple question. Figure 1 shows that if the line AB is extended, it somewhere intersects the rectangle at C. My question is how to find the intersection point C. I know the coordinates of A and B.

**0**

# A simple question on mathematics

###
#3
Crossbones+ - Reputation: **7160**

Posted 22 January 2013 - 02:45 PM

Ray with t as independent variable: **R**(t) := **A** + t * ( **B** - **A** )

An edge (exemplarily one of the four building the rectangle) with k_{1} as independent variable: **E**_{1}(k_{1}) := [-1,-1] + k_{1} * [1,0]

Then **R**(t) = **E**_{1}(k) gives the point of intersection. These are 2 linear equations with 2 independents what can be solved symbolically. The result cannot be computed (or, to be precise, gives infinity of negative infinity) if **R**(t) is parallel or anti-parallel to **E**_{1}(k_{1}). Otherwise a specific pair (t',k_{1}') can be computed. To be valid, k_{1}' must be in the interval [0,+1], and t' must be greater than 0. If so, then **R**(t') and **E**_{1}(k_{1}) is the solution. Otherwise another edge has to be investigated.