Detecting when a trace crosses a gap between two positions?

Sorry for the title, I mean’t four, it’s not much of a difference though. So, uhm, I’m having some trouble detecting when a trace crosses the gap between four positions (world).
Wait actually two… whatever.

(Awesome picture)
Basically when this happens.

Check the delta of the distance?

Trace’s hitpos isn’t on the “square” the four positions make, so if it’s crossing the gap it doesn’t mean it’s on the gap, therefore I can’t properly detect the distance…

[editline]23rd November 2011[/editline]

[lua]local function TheLine( lineStart, lineEnd, planeNormal, planePoint ) – Overv’s plane intersection “linePlaneIntersect”
local d = planeNormal:Dot( lineEnd - lineStart )
if ( d == 0 ) then return false end
local t = planeNormal:Dot( planePoint - lineStart ) / d
if ( t < 0 ) then return false end
return lineStart + t * ( lineEnd - lineStart )
Found in an old gamemode. It works well.