Find the intersection of two lines: Difference between revisions

Added AutoHotkey
(Added Wren)
(Added AutoHotkey)
Line 242:
5.0000 5.0000
</pre>
 
=={{header|AutoHotkey}}==
<lang AutoHotkey>LineIntersectionByPoints(L1, L2){
x1 := L1[1,1], y1 := L1[1,2]
x2 := L1[2,1], y2 := L1[2,2]
x3 := L2[1,1], y3 := L2[1,2]
x4 := L2[2,1], y4 := L2[2,2]
return ((x1*y2-y1*x2)*(x3-x4) - (x1-x2)*(x3*y4-y3*x4)) / ((x1-x2)*(y3-y4) - (y1-y2)*(x3-x4)) ", "
. ((x1*y2-y1*x2)*(y3-y4) - (y1-y2)*(x3*y4-y3*x4)) / ((x1-x2)*(y3-y4) - (y1-y2)*(x3-x4))
}</lang>
Examples:<lang AutoHotkey>L1 := [[4,0], [6,10]]
L2 := [[0,3], [10,7]]
MsgBox % LineIntersectionByPoints(L1, L2)</lang>
Outputs:<pre>5.000000, 5.000000</pre>
 
=={{header|AWK}}==
299

edits