calc-line-slope ( point1 point2 -- slope )


Vocabulary
ui.gadgets.charts.lines.private

Word description
Given the two points belonging to a straight line, calculate the slope of the line, assuming the line equation is y(x) = slope * x + b.

Inputs and outputs
point1an object
point2an object
slopean object



The formula for the calculation is slope = (y1-y2) / (x1-x2), therefore it'll throw a division by zero error if both points have the same x coordinate.

Examples
USING: ui.gadgets.charts.lines.private prettyprint ; { 1 1 } { 10 10 } calc-line-slope .
1

USING: ui.gadgets.charts.lines.private prettyprint ; { 0 0 } { 10 20 } calc-line-slope .
2


See also
y-at, calc-x, calc-y

Definition