Function TriAreaSize(ByVal ax As Double, ByVal ay As Double, ByVal bx As Double, ByVal by As Double, ByVal cx As Double, ByVal cy As Double) As Double
TriAreaSize = ((ax - cx) * (by - cy) - (ay - cy) * (bx - cx)) * 0.5
End Function
Function GetIfTwoLineIntr(ByVal ax As Double, ByVal ay As Double, ByVal bx As Double, ByVal by As Double, _
ByVal cx As Double, ByVal cy As Double, ByVal dx As Double, ByVal dy As Double, _
ByRef IntrX As Double, ByRef IntrY As Double) As Boolean
Dim area_abc, area_abd As Double
Dim area_cda, area_cdb As Double
Dim t, ddx, ddy As Double
GetIfTwoLineIntr = True
area_abc = Nis_Fun.TriAreaSize(ax, ay, bx, by, cx, cy)
area_abd = Nis_Fun.TriAreaSize(ax, ay, bx, by, dx, dy)
If area_abc * area_abd < 0 Then Exit Function
area_cda = Nis_Fun.TriAreaSize(cx, cy, dx, dy, ax, ay)
area_cdb = Nis_Fun.TriAreaSize(cx, cy, dx, dy, bx, by)
If area_cda * area_cdb < 0 Then Exit Function
GetIfTwoLineIntr = False
t = area_cda / (area_abd - area_abc)
ddx = t * (bx - ax)
ddy = t * (by - ay)
IntrX = ax + ddx
IntrY = ay + ddy
End Function