class Geometry · Computations

Distribute

Places points evenly along a segment, arc, circle, polygon or polyline.

Static methods

pointsAlongSegmentstatic

static pointsAlongSegment(points: Point[], p1: Point | VectorLike, p2: Point | VectorLike): Point[]

Distributes the given points evenly along a line segment.

points
The points to distribute. The sequence is modified in place.
p1
The start point of the segment.
p2
The end point of the segment.

Returns The modified sequence of points after distribution.

static pointsAlongSegment(points: Point[], p1: Point | VectorLike, p2: Point | VectorLike, distance: Real | NumberLike, side: Bool | BoolLike): Point[]

Distributes the given points evenly along a line segment, optionally offset to one side by a specified distance.

If the segment from p1 to p2 is degenerate (both points are identical), the offset direction defaults to the positive X axis. Points are distributed evenly between the (possibly offset) start and end points.

points
The sequence of points to distribute. The points are modified in place.
p1
The start point of the base segment.
p2
The end point of the base segment.
distance
The perpendicular distance to offset the points from the base segment. If zero, points are distributed directly along the segment.
side
Determines the side on which points are offset relative to the base segment. The direction is relative to the segment from p1 to p2.

Returns The same sequence of points after being redistributed along the segment.

pointsOnArcstatic

static pointsOnArc(points: Point[], center: Point | VectorLike, radius: Real | NumberLike, startDir: Vector | VectorLike, endDir: Vector | VectorLike, clockwise: Bool | BoolLike): Point[]

Distributes a sequence of points evenly along an arc of a circle.

points
The sequence of points to distribute. This sequence is modified in place.
center
The center point of the arc.
radius
The radius of the arc.
startDir
The starting direction of the arc.
endDir
The ending direction of the arc.
clockwise
If true, points are distributed in a clockwise direction; otherwise, counter-clockwise.

Returns The sequence of points after they have been distributed along the arc.

pointsOnCirclestatic

static pointsOnCircle(points: Point[], circle: Circle | ShapeLike, angleOffset: Real | NumberLike, clockwise: Bool | BoolLike): Point[]

Distributes the given points evenly along a circle.

points
The points to distribute. The sequence is modified in place.
circle
The target circle along which to distribute points.
angleOffset
An angular offset applied to the distribution.
clockwise
If true, points are distributed in a clockwise direction; otherwise, counter-clockwise.

Returns The modified sequence of points after distribution.

pointsOnPolygonstatic

static pointsOnPolygon(points: Point[], polygon: Polygon | ShapeLike): Point[]

Distributes the given points evenly along the edges of a polygon.

points
The points to distribute. The sequence is modified in place.
polygon
The polygon along whose edges the points are distributed.

Returns The modified sequence of points after distribution.

pointsOnPolylinestatic

static pointsOnPolyline(points: Point[], polyline: Polyline | ShapeLike): Point[]

Distributes the given points evenly along a polyline.

points
The points to distribute. The sequence is modified in place.
polyline
The polyline along which the points are distributed.

Returns The modified sequence of points after distribution.