Find the intersection of two lines: Difference between revisions

Content added Content deleted
Line 422: Line 422:
define :line [a, b][
define :line [a, b][
init: [
init: [
this\slope: (this\b\y-this\a\y) / (this\b\x-this\a\x)
this\slope: div this\b\y-this\a\y this\b\x-this\a\x
this\yInt: this\a\y - this\slope * this\a\x
this\yInt: this\a\y - this\slope*this\a\x
]
]
]
]
Line 432: Line 432:


intersect: function [line1, line2][
intersect: function [line1, line2][
x: (line2\yInt - line1\yInt) / (line1\slope - line2\slope)
x: div line2\yInt-line1\yInt line1\slope-line2\slope
y: evalX line1 x
y: evalX line1 x