This class represents a line segment in the plane.
Remarks
A line segment is defined by its two end points.
Type Details
- yfiles module
- algorithms
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.algorithms.LineSegment
Constructors
Returns a new LineSegment.
Properties
Gets the smallest Rectangle which contains the object.
Implements
Gets the first end point of the line segment.
Gets the second end point of the line segment.
Methods
Checks whether the line segment intersects a box.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- box - YRectangle
- A rectangle.
Returns
- ↪boolean
true
if the line segments intersects the box,false
otherwise.
Returns the affine line defined by the end points of the line segment.
Returns the vector pointing from the first end point to the second end point of the line segment.
Static Methods
Checks whether a line segment intersects a box.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- box - YRectangle
- A rectangle.
- s - YPoint
- first end point of the line segment.
- t - YPoint
- second end point of the line segment.
Returns
- ↪boolean
true
if the line segments intersects the box,false
otherwise.
Checks whether a line segment intersects a box.
Remarks
Implemented using the Cohen-Sutherland algorithm.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- box - YRectangle
- A rectangle
- x1 - number
- x-coordinate of the first end point of the line segment
- y1 - number
- y-coordinate of the first end point of the line segment
- x2 - number
- x-coordinate of the second end point of the line segment
- y2 - number
- y-coordinate of the second end point of the line segment
Returns
- ↪boolean
true
if the line segment intersects the box,false
otherwise.
boxIntersectsSegment
(boxX1: number, boxY1: number, boxX2: number, boxY2: number, sX1: number, sY1: number, sX2: number, sY2: number) : booleanChecks whether a line segment intersects a paraxial box.
Remarks
Implemented using the Cohen-Sutherland algorithm.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- boxX1 - number
- x-coordinate of the upper left corner of the box
- boxY1 - number
- y-coordinate of the upper left corner of the box
- boxX2 - number
- x-coordinate of the lower right corner of the box
- boxY2 - number
- y-coordinate of the lower right corner of the box
- sX1 - number
- x-coordinate of the first end point of the line segment
- sY1 - number
- y-coordinate of the first end point of the line segment
- sX2 - number
- x-coordinate of the second end point of the line segment
- sY2 - number
- y-coordinate of the second end point of the line segment
Returns
- ↪boolean
true
if the line segment intersects the box,false
otherwise.
Returns intersection point between the two line segments, if there is one or null
if the two line segments do not intersect.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- s1 - LineSegment
- first line segment
- s2 - LineSegment
- second line segment