skspatial.objects.Line.from_slope

classmethod Line.from_slope(slope: float, y_intercept: float) skspatial.objects.line.Line[source]

Instantiate a 2D line from a slope and Y-intercept.

A 2D line can be represented by the equation

\[y = mx + b\]

where \(m\) is the slope and \(p\) is the Y-intercept.

Parameters
slope{int, float}

Slope of the 2D line.

y_intercept{int, float}

Y coordinate of the point where the line intersects the Y axis.

Returns
Line

A 2D Line object.

Examples

>>> from skspatial.objects import Line
>>> Line.from_slope(2, 0)
Line(point=Point([0, 0]), direction=Vector([1, 2]))
>>> Line.from_slope(-3, 5)
Line(point=Point([0, 5]), direction=Vector([ 1, -3]))
>>> line_a = Line.from_slope(1, 0)
>>> line_b = Line.from_slope(0, 5)
>>> line_a.intersect_line(line_b)
Point([5., 5.])