Jump to content

Find the intersection of two lines: Difference between revisions

m
Line 1,149:
class line {
private:
slop, Xz, Yzk
public:
function f(x) {
=x*.slop*(x-.xz)+.yzk
}
function intersection(b as line) {
Line 1,158:
=(,)
else
x1=(.k-b.xz*b.slop+b.yz+.xz*.slop-.yzk)/(.slop-b.slop)
=(x1, .f(x1))
end if
Line 1,167:
if x1==x2 then error "wrong input"
if x1>x2 then swap x1,x2 : swap y1, y2
(.slop, .xz, .yz)<=((y1-y2)/(x1-x2), x1, y1)
.k<=x1*.slop-y1
}
}
404

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.