And here I'm again making math questions.
Currently (thanks to Zylann), I have a function that detects if a 2D line intersects with another. It works, with the exception of one situation: If the line is inside another while having the same angle (e. g.
(0, 0), (0, 100), (0, 50), (0, 150)), it will not treat it as an intersection.
Here is the current code:
func are_lines_intersecting(a, b, c, d):
var cd = d - c
var ab = b - a
var div = cd.y * ab.x - cd.x * ab.y
if abs(div) > 0.001:
var ac = a - c
var ua = ((cd.x * ac.y) - (cd.y * ac.x)) / div
if not ua >= 0.0 or not ua <= 1.0:
var ub = ((ab.x * ac.y) - (ab.y * ac.x)) / div
if ub >= 0.0 and ub <= 1.0: