I've been trying to solve this and I found an equation that gives the possibility of zero division errors. Not the best thing:
v1 = (a,b)
v2 = (c,d)
d1 = (e,f)
d2 = (h,i)
l1: v1 + λd1
l2: v2 + µd2
Equation to find vector intersection of l1 and l2 programatically by re-arranging for lambda.
(a,b) + λ(e,f) = (c,d) + µ(h,i)
a + λe = c + µh
b +λf = d + µi
µh = a + λe - c
µi = b +λf - d
µ = (a + λe - c)/h
µ = (b +λf - d)/i
(a + λe - c)/h = (b +λf - d)/i
a/h + λe/h - c/h = b/i +λf/i - d/i
λe/h - λf/i = (b/i - d/i) - (a/h - c/h)
λ(e/h - f/i) = (b - d)/i - (a - c)/h
λ = ((b - d)/i - (a - c)/h)/(e/h - f/i)
Intersection vector = (a + λe,b + λf)
Not sure if it would even work in some cases. I haven't tested it.
I need to know how to do this for values as in that example a-i.
Thank you.