Creates a new LineSegment2
from its endpoints.
Readonly
bboxThe bounding box of this line segment.
Readonly
directionThe unit direction vector of this line segment, from
point1
to point2
.
In other words, direction
is point2.minus(point1).normalized()
(perhaps except when point1
is equal to point2
).
Readonly
lengthThe distance between point1
and point2
.
Returns the parameter values at which lineSegment
intersects this shape.
See also intersectsLineSegment
Returns true
if and only if the given point
is contained within this shape.
epsilon
is a small number used to counteract floating point error. Thus, if
point
is within epsilon
of the inside of this shape, containsPoint
may also
return true
.
The default implementation relies on signedDistance
.
Subclasses may override this method to provide a more efficient implementation.
Returns true
iff this is equivalent to other
.
Options:
tolerance
: The maximum difference between endpoints. (Default: 0)ignoreDirection
: Allow matching a version of this
with opposite direction. (Default: true
)Optional
options: { ignoreDirection?: boolean; tolerance?: number }Returns a bounding box that loosely fits the content of this shape.
The result of this call can be larger than the result of getTightBoundingBox,
but should not be smaller. Thus, a call to getLooseBoundingBox
can be significantly
faster than a call to getTightBoundingBox for some shapes.
Returns the intersection of this with another line segment.
WARNING: The parameter value returned by this method does not range from 0 to 1 and is currently a length. This will change in a future release.
Returns the points at which this line segment intersects the given line segment.
Note that intersects returns whether this line segment intersects another line segment. This method, by contrast, returns the point at which the intersection occurs, if such a point exists.
Divides this shape into two separate shapes at parameter value .
Returns a copy of this line segment transformed by the given affineTransfm
.
Static
ofReturns the smallest line segment that contains all points in points
, or null
if no such line segment exists.
Represents a line segment. A
LineSegment2
is immutable.Example