Apologies, I should've commented it
Just for completeness, here is the outline to my method:
- Plane can be described by:[color=green](x - x0) · n = 0[/color]Where [color=blue][color=green]x[/color] [/color]is any point in the plane, [color=green]x0[/color] is a fixed point in the plane and [color=green]n[/color] is the plane normal.Just using the fact that any vector in the plane will be perpendicular to the plane normal => Dot product between those vectors = 0Line can be decribed by:[color=green]y = y0 + vt[/color]Where [color=green]y [/color]is a point on the line, [color=green]y0[/color] is a fixed point on the line, [color=green]v [color=black]is the direction vector of the line, and[/color] t[/color] is the parameter, For intersection we want [color=green]x = y[/color], hence:[color=green](y0 + vt - x0) · n = 0[color=black]Dot product is distributive, so:[color=green]vt [/color][/color][/color][color=green]· n + (y0 - x0) [/color][color=green]· n = 0[color=black]Finally, rearranging for our parameter [color=green]t:t = (y0 - x0) [/color][/color][/color][color=green]· n / v [/color][color=green]· n[color=black]If the line is parallel to the plane, its direction vector will beperpendicular to the plane normal, and hence [/color][/color][color=green]v [/color][color=green]· n = 0[color=black]So we test for that before performing the division.[/color][/color]
Hope this clarifies things better. |