A 2D line segment.

See also:

Constructor

inlinenew(p1:Point, p2:Point)

Create a new Segment starting from Point p1 and ending at Point p2.

Variables

dx:Float

The delta-value of X end position of the Segment relative to starting position.

Please use Segment.setPoints to modify this value.

dy:Float

The delta-value of Y end position of the Segment relative to starting position.

Please use Segment.setPoints to modify this value.

invLenSq:Float

Inverse of the Segments squared length.

Please use Segment.setPoints to modify this value.

lenSq:Float

Squared length of the segment.

Please use Segment.setPoints to modify this value.

x:Float

X starting position of the Segment.

Please use Segment.setPoints to modify this value.

y:Float

Y starting position of the Segment.

Please use Segment.setPoints to modify this value.

Methods

inlinedistance(p:Point):Float

Returns distance from the Segment as an infinite line to the Point p.

inlinedistanceSq(p:Point):Float

Returns squared distance to the Segment as an infinite line to the Point p.

inlinelineIntersection(r:Ray, ?pt:Point):Null<Point>

Tests if Segments intersects given Ray r.

Parameters:

pt

Optional Point instance to which intersection point is written. If not provided, returns new Point instance.

Returns:

A Point with intersection position or null if Segment and Ray do not intersect.

inlineproject(p:Point, ?out:Point):Point

Projects Point p onto Segment. Returns position of intersection between Segment and line perpendicular to it going through Point p.

Parameters:

p

Point to project onto this Segment.

out

Optional Point instance to which projection point is written. If not provided, returns new Point instance.

Returns:

A Point with projection position.

inlinesetPoints(p1:Point, p2:Point):Void

Sets Segment starting position at Point p1 and ending position at Point p2.

inlineside(p:Point):Float

Returns a positive value if Point p is on the right side of the Segment axis and negative if it's on the left.