Find the intersection of two lines: Difference between revisions
Find the intersection of two lines (view source)
Revision as of 07:34, 23 September 2020
, 3 years ago→{{header|M2000 Interpreter}}: more compact
m (→{{header|M2000 Interpreter}}: more compact) |
|||
Line 1,149:
class line {
private:
slop,
public:
function f(x) {
=x*.slop
}
function intersection(b as line) {
Line 1,158:
=(,)
else
x1=(.k-b.
=(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
.k<=x1*.slop-y1
}
}
|