Skip to content

Main content

Polyline Rectangle Clip

Clip each polyline segment independently, retaining source-segment indexes and boundary point intersections instead of inventing path continuity.

Loading tool…

Description

Clip each polyline segment independently, retaining source-segment indexes and boundary point intersections instead of inventing path continuity.

Planar geometry operates on two-coordinate Cartesian points and explicit shape boundaries. A closed rectangle includes its edges, while a segment parameter locates a point along a supporting line. Signed cross products, areas and axis gaps preserve orientation or direction information that a magnitude alone would lose.

Clip each polyline segment independently, retaining source-segment indexes and boundary point intersections instead of inventing path continuity.

When to use this tool

Use this tool to clip each polyline segment independently, retaining source-segment indexes and boundary point intersections instead of inventing path continuity.

How to use the tool and how it works

  1. Enter points, rectangle using the input definitions below.
  2. Run the operation. Resolve malformed-input errors before interpreting the result.
  3. Read result.segments. Interpret signs, units, ordering and null values using the rules below.

Clip every adjacent point pair independently to the closed rectangle. Keep each non-null clipped segment with the index of its source pair, including intersections that collapse to a point.1

Input fieldMeaning and unitsAccepted input
pointsOrdered planar [x,y] points. Polygon operations close the cycle implicitly; polyline operations use adjacent pairs only.Dense list of at most 128 rows of at most 128 finite numbers; the operation’s shape constraints also apply.
rectangleClosed rectangle [minX,minY,maxX,maxY]; equal bounds are allowed.Dense list of at most 128 finite numbers, subject to the stated integer/shape rules.
Output fieldInterpretation
resultObject containing the fields below.
result.segmentsIndependent clipped segment records with sourceSegment indexes and endpoint pairs.
json
{
  "input": {
    "points": [
      [
        -1,
        1
      ],
      [
        3,
        1
      ],
      [
        4,
        1
      ]
    ],
    "rectangle": [
      0,
      0,
      2,
      2
    ]
  },
  "output": {
    "result": {
      "segments": [
        {
          "sourceSegment": 0,
          "points": [
            [
              0,
              1
            ],
            [
              2,
              1
            ]
          ]
        }
      ]
    }
  }
}

Limitations and assumptions

  • The output is a list of segment observations; it does not stitch disconnected pieces into continuous polylines.
  • Point components and rectangle bounds are finite within ±1,000,000,000. Rectangles use [minX,minY,maxX,maxY] with ordered inclusive bounds. Floating arithmetic is used without an implicit robustness tolerance.
  • Every declared top-level input is required and unknown fields are rejected. Ordinary strings are limited to 8,192 UTF-16 code units and lists to 128 entries, with tighter operation-specific bounds where stated. JSON text has bounded nesting and node counts.
  • Numeric outputs must be finite and within the absolute safe-integer magnitude; exact larger integers use decimal text. Source positions are zero-based UTF-16 offsets and span ends are exclusive unless a different convention is explicitly stated.

Alternative or Complementary methods

Choose the boundary and coordinate convention explicitly. Use robust geometric predicates or a topology-aware library when near-coincidence, holes, invalid polygons or geographic coordinates matter.

References

  1. Tool behavior and example: Polyline Rectangle Clip — tool.io

Similar or alternative tools

  • Polygon Rectangle Clip

    Clip an ordered planar polygon against four rectangle half-planes, preserving algorithm order; floating boundary arithmetic, no polygon topology repair.

  • Segment Rectangle Clip

    Clip one closed planar segment to an inclusive axis-aligned rectangle using parameter bounds; null means no intersection.