LineSegment class

A LineSegment represent a segment of an infinitely long line, it is the segment between the from and to vectors (inclusive).

Constructors

LineSegment.new(Vector2 from, Vector2 to)
Creates a LineSegment given a start (from) point and an end (to) point.
LineSegment.withLength({required Vector2 start, required Vector2 direction, required double length})
Creates a LineSegment starting at a given a start point and following a certain direction for a given length.
LineSegment.zero()
factory

Properties

direction Vector2
A unit vector representing the direction of the line segment.
no setter
from Vector2
final
hashCode int
The hash code for this object.
no setterinherited
length double
The length of the line segment.
no setter
midpoint Vector2
The point in the center of this line segment.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
to Vector2
final

Methods

containsPoint(Vector2 point, {double epsilon = 0.000001}) bool
Whether the given point lies in this line segment.
deflate(double amount) LineSegment
Returns a new LineSegment with same direction but reduced by amount on both sides.
inflate(double amount) LineSegment
Returns a new LineSegment with same direction but extended by amount on both sides.
intersections(LineSegment otherSegment) List<Vector2>
Returns an empty list if there are no intersections between the segments If the segments are concurrent, the intersecting point is returned as a list with a single point
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pointsAt(Line line) bool
spread(int amount) List<Vector2>
Spreads points evenly along the line segment. A number of points amount are returned; the edges are not included.
toLine() Line
toString() String
A string representation of this object.
override
translate(Vector2 offset) LineSegment
Returns a new LineSegment translated by a given displacement offset.

Operators

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