Line class

A line segment defined by two endpoints a and b.

Provides geometric operations including slope, intercepts, intersection detection, distance calculations, and projections.

final line = Line(Point(0, 0), Point(4, 3));
print(line.length);   // 5.0
print(line.midPoint);  // Point(2, 1.5)

Constructors

Line(Point a, Point b)
Creates a line segment from point a to point b.
const

Properties

a Point
First endpoint.
final
b Point
Second endpoint.
final
hashCode int
The hash code for this object.
no setteroverride
isHorizontal bool
Whether this line segment is horizontal (same y for both endpoints)
no setter
isVertical bool
Whether this line segment is vertical (same x for both endpoints)
no setter
length double
Length of this line
no setter
midPoint Point
The midpoint of the line
no setter
points List<Point>
Get list of points
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
slope double
Get slope of this line
no setter
xIntercept double
Get the x-intercept of this line
no setter
yIntercept double
Get the y-intercept of this line
no setter

Methods

distanceFromAPoint(Point point) double
get the distance from a points to this line
extend(double amount) Line
Return new line extended by amount from both ends
getAngleWith(Line other) Rad
Get the angle between this line and another line
getIntersectPoint(Line other) Point?
Get Intersect point of this line and another line
hasPoint(Point point) bool
Check if a point is belong to this line
innerAngleWith(Line other) Rad
Get the inner angle between this line and another line
intersect(Line other) bool
Check if this line and other line intersect
isParallelTo(Line other) bool
Check if this line is parallel to other
isPerpendicularTo(Line other) bool
Check if this line is perpendicular to other
lerp(double t) Point
Get point at parameter t along segment
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
outerAngleWith(Line other) Rad
Get the outer angle between this line and another line
projectPoint(Point point) Point
Get closest point on this line segment to point
rotate(double deg) Line
Rotate the line by deg degrees
scale(double factor) Line
Scale the line by factor
toString() String
A string representation of this object.
override
translate({double x = 0, double y = 0}) Line
Translate the line by x horizontally and y vertically

Operators

operator ==(Object other) bool
The equality operator.
override