Finding the intersection of two vector equations.
- by Matthew Mitchell
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.