Finding a line/ trapezoid intersection through system of equations

• Mar 28th 2011, 01:45 AM
Durruti
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
• Mar 28th 2011, 08:17 AM
Ackbeet
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:

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

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

Parametrize your test line in the same way:

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

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

Make sense?
• Mar 28th 2011, 11:37 PM
Durruti
Thanks! a question though, what is "a" in the interval?
• Mar 29th 2011, 02:43 AM
Ackbeet
$a_{1}$ is the left-hand boundary for the interval $[a_{1},b_{1}].$ For example, if

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

Does that make sense?
• Mar 31st 2011, 05:19 AM
Durruti
Just browsing by to say a thanks a lot . The solution is great, working with wind turbine wakes here.
• Mar 31st 2011, 05:31 AM
Ackbeet
Great! You're very welcome for any help I could give. Have a good one!