class Geometry · Computations
Offsets
Creates offset shapes: contours around shapes, routes beside a polyline, and points beside a segment.
Static methods
besideRoutestatic
static besideRoute(points: Sequence<Vector> | VectorsLike, distance: Real | NumberLike, left: Bool | BoolLike, cornerRefinement: Integer | NumberLike, result?: Polyline | null): PolylineA baseline beside a route, e.g. for an elevation profile: the outline of the route's points
on its left or right side, distance away, from beside the first point to beside the last
point, running in the route's direction.
Sides are relative to the direction of travel (first point → last point; on screen, a route
running to the right has left = up). The baseline runs the same way as the route, so the same
left points away from the route on it too: Polylines.pointBeside(baseline, ratio, height, left), Polylines.parallel and Curves.alongPolylineAtRatios draw outward with the value
passed here.
Construction: the convex hull of the points, grown by distance (edges moved out, corners
rounded with cornerRefinement points per corner, 0 = cut straight), on the chosen side of
the line from the first to the last point, cut by the perpendiculars through these two
points. It depends only on the points: panning or zooming the map moves it with the route.
For a loop (first point = last point) the chord runs from the first point to the point
farthest from it. Parts of the route beyond the two perpendiculars are not covered. Negative
distances count as 0.
With result, the values are written into its vertices (vertices are added or removed at the
end), so a visual passed as result follows.
points- The route's points, in the direction of travel.
distance- The distance between the route and the baseline.
lefttruefor the left side of the direction of travel,falsefor the right.cornerRefinement- The number of points inside each rounded corner (0 = cut straight).
resultoptional- Optional
Polylineto write the result into; it is returned. Without it, a newPolylineis returned.
Returns The baseline, running from beside the first point to beside the last point.
convexContourstatic
static convexContour(points: Sequence<Vector> | VectorsLike, distance: Real | NumberLike, cornerRefinement: Integer | NumberLike, result?: Polygon | null): PolygonComputes a convex offset polygon around a sequence of points.
points- The points to offset.
distance- The offset distance.
cornerRefinement- The number of points to refine corners.
resultoptional- Optional
Polygonto write the result into; it is returned. Without it, a newPolygonis returned.
Returns A convex polygon offset from the given points by distance.
convexOneSidedContourstatic
static convexOneSidedContour(points: Sequence<Vector> | VectorsLike, distance: Real | NumberLike, left: Bool | BoolLike, cornerRefinement: Integer | NumberLike, result?: Polyline | null): PolylineComputes a one-sided convex offset polyline from a sequence of points.
Deprecated. Use Offsets.besideRoute, whose sides are relative to the direction of travel.
points- The points to offset.
distance- The offset distance.
lefttrueto offset to the left,falsefor the right.cornerRefinement- The number of points to refine corners.
resultoptional- Optional
Polylineto write the result into; it is returned. Without it, a newPolylineis returned.
Returns A polyline offset to one side of the input points.
pointAtSegmentstatic
static pointAtSegment(segment: Segment | ShapeLike, distance: Real | NumberLike, ratio: Real | NumberLike, left: Bool | BoolLike, result?: Point | null): PointComputes a point offset along a line segment at a given distance and ratio.
segment- The segment along which to compute the point.
distance- The offset distance.
ratio- The relative position along the segment (0 to 1).
lefttrueif offset is to the left,falseto the right.resultoptional- Optional
Pointto write the result into; it is returned. Without it, a newPointis returned.
Returns The computed offset point along the segment.
pointAtSegmentEndstatic
static pointAtSegmentEnd(segment: Segment | ShapeLike, distance: Real | NumberLike, left: Bool | BoolLike, result?: Point | null): PointComputes a point at the end of a line segment with an offset.
segment- The line segment.
distance- The offset distance.
lefttrueif offset is to the left,falseto the right.resultoptional- Optional
Pointto write the result into; it is returned. Without it, a newPointis returned.
Returns The offset point at the end of the segment.
pointAtSegmentStartstatic
static pointAtSegmentStart(segment: Segment | ShapeLike, distance: Real | NumberLike, left: Bool | BoolLike, result?: Point | null): PointComputes a point at the start of a line segment with an offset.
segment- The line segment.
distance- The offset distance.
lefttrueif offset is to the left,falseto the right.resultoptional- Optional
Pointto write the result into; it is returned. Without it, a newPointis returned.
Returns The offset point at the start of the segment.
polygonstatic
static polygon(baseline: Polygon | ShapeLike, distance: Real | NumberLike, left: Bool | BoolLike, cornerRefinement: Integer | NumberLike, result?: Polygon | null): PolygonComputes a polygon offset from a baseline polygon by a given distance.
This method is intended for use with convex baseline polygons. Using non-convex baselines may result in self-intersections in the offset polygon.
baseline- The baseline polygon.
distance- The offset distance.
lefttrueif offset is to the left,falseto the right.cornerRefinement- The number of points to refine corners.
resultoptional- Optional
Polygonto write the result into; it is returned. Without it, a newPolygonis returned.
Returns The offset polygon.
polylinestatic
static polyline(baseLine: Polyline | ShapeLike, distance: Real | NumberLike, left: Bool | BoolLike, cornerRefinement: Integer | NumberLike, result?: Polyline | null): PolylineComputes a polyline offset from a baseline polyline by a given distance.
This method is intended for use with convex baseline polylines. Using non-convex baselines may result in self-intersections in the offset polyline.
baseLine- The baseline polyline.
distance- The offset distance.
lefttrueif offset is to the left,falseto the right.cornerRefinement- The number of points to refine corners.
resultoptional- Optional
Polylineto write the result into; it is returned. Without it, a newPolylineis returned.
Returns The offset polyline.
