Skip to content

Main content

Segment Intersection Witness

Return planar closed-segment intersection witnesses, including degenerate-point and collinear overlap cases; exact floating comparisons, no robust geometry guarantee.

Loading tool…

Description

Return planar closed-segment intersection witnesses, including degenerate-point and collinear overlap cases; exact floating comparisons, no robust geometry guarantee.

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.

Return planar closed-segment intersection witnesses, including degenerate-point and collinear overlap cases; exact floating comparisons, no robust geometry guarantee.

When to use this tool

Use this tool to return planar closed-segment intersection witnesses, including degenerate-point and collinear overlap cases; exact floating comparisons, no robust geometry guarantee.

How to use the tool and how it works

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

For nonparallel segment directions solve both line parameters and retain a point only when both lie in [0,1]. For parallel or degenerate cases collect shared endpoints, remove exact repeats, and sort by x then y; return none, point or overlap with overlap endpoints.1

Input fieldMeaning and unitsAccepted input
aFirst point [x,y]; for segment-pair tools this is the first segment’s start.Dense list of at most 128 finite numbers, subject to the stated integer/shape rules.
bSecond point [x,y]; for segment-pair tools this is the first segment’s end.Dense list of at most 128 finite numbers, subject to the stated integer/shape rules.
cThird point [x,y]; for segment-pair tools this is the second segment’s start.Dense list of at most 128 finite numbers, subject to the stated integer/shape rules.
dSecond segment’s end point [x,y].Dense list of at most 128 finite numbers, subject to the stated integer/shape rules.
Output fieldInterpretation
resultObject containing the fields below.
result.kindIntersection class: none, point or overlap.
result.pointsOrdered resulting point coordinates under the stated clipping/intersection rule.
json
{
  "input": {
    "a": [
      0,
      0
    ],
    "b": [
      2,
      2
    ],
    "c": [
      0,
      2
    ],
    "d": [
      2,
      0
    ]
  },
  "output": {
    "result": {
      "kind": "point",
      "points": [
        [
          1,
          1
        ]
      ]
    }
  }
}

Limitations and assumptions

  • Exact floating comparisons decide parallelism and collinearity; nearly coincident geometry can be sensitive to roundoff.
  • 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: Segment Intersection Witness — tool.io

Similar or alternative tools