# Thread: Finding a line/ trapezoid intersection through system of equations

1. ## Finding a line/ trapezoid intersection through system of equations

Hello, I have a problem that I so far haven't been able to solve, I know it includes geometry but I need to find a way to solve it looking at it as functions, a system of linear equations or such that might be solved in a matrix. I want to find out if a line( finite) is either inside or intersecting a trapezoid. I know that the line can never be intersecting the trapezoid twice and the line is always parallel to the parallel lines of the trapezoid. I have tried to find an approach using a parametrized equation of the plane and line intersection but I dont think it covers all cases.
( something like this ( from wikipedia) : la+(lb+la)t=p0+(p1-p0)u+(p2-p0)v

thanks

2. Here's an idea.

1. Your test line is parallel to the parallel lines of the trapezoid. Hence, there's no need to test for intersection with the parallel lines.
2. Parametrize the non-parallel lines of the trapezoid as follows:

$\displaystyle y_{1}=m_{1}t+b_{1},\quad t\in[a_{1},b_{1}],$ and

$\displaystyle y_{2}=m_{2}t+b_{2},\quad t\in[a_{2},b_{2}].$

Parametrize your test line in the same way:

$\displaystyle z=m_{z}t+b_{z},\quad t\in[a_{z},b_{z}].$

3. Attempt to solve, one after the other, the equations $\displaystyle z=y_{1},$ and $\displaystyle z=y_{2}$ for $\displaystyle t.$ In both cases, there should be exactly one solution, since the lines are obviously not parallel. Test the value of $\displaystyle t$ and see if it is inside both allowable ranges. For example, if you're solving $\displaystyle z=y_{1},$ then make sure both that $\displaystyle t\in[a_{1},b_{1}]$ and $\displaystyle t\in[a_{z},b_{z}].$ If so, then you have an intersection. Otherwise, you don't.

Make sense?

3. Thanks! a question though, what is "a" in the interval?

4. $\displaystyle a_{1}$ is the left-hand boundary for the interval $\displaystyle [a_{1},b_{1}].$ For example, if

$\displaystyle [a_{1},b_{1}]=[2,5],$ then $\displaystyle a_{1}=2$ and $\displaystyle b_{1}=5.$

Does that make sense?

5. Just browsing by to say a thanks a lot . The solution is great, working with wind turbine wakes here.

6. Great! You're very welcome for any help I could give. Have a good one!