Skip to content

Main content

Segment Endpoint Distance Choice

Choose the nearest or farthest explicit endpoint distance, resolving exact ties to the first endpoint.

Loading tool…

Description

Choose the nearer or farther of two supplied endpoint distances.

Distance calculations require a metric, coordinate convention, unit basis and tie policy. Selecting the nearer endpoint differs from computing distance to the full segment. A circular shortest-angle difference also needs an explicit choice between equally short positive and negative half turns.

Choose the nearer or farther of two supplied endpoint distances.

When to use this tool

Use Segment Endpoint Distance Choice when you already have firstEndpointDistance, secondEndpointDistance, chooseFarthest and need to choose the nearer or farther of two supplied endpoint distances.

How to use the tool and how it works

  1. Enter firstEndpointDistance, secondEndpointDistance, chooseFarthest. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read selectedDistance, firstEndpointChosen. Inspect firstEndpointChosen before interpreting the associated values.

Require both distances>=0; choose min or max and report firstEndpointChosen using inclusive comparison.1

Input fieldMeaning and unitsAccepted input
firstEndpointDistanceFirst Endpoint DistanceRequired. Finite number; minimum 0.
secondEndpointDistanceSecond Endpoint DistanceRequired. Finite number; minimum 0.
chooseFarthestChoose FarthestRequired. Boolean.
Output fieldInterpretationReturned shape
selectedDistanceSelected DistanceRequired. Finite number.
firstEndpointChosenTrue on equality under both nearest and farthest selection policies.Required. Boolean.
json
{
  "input": {
    "firstEndpointDistance": 3,
    "secondEndpointDistance": 5,
    "chooseFarthest": false
  },
  "output": {
    "selectedDistance": 3,
    "firstEndpointChosen": true
  }
}

Limitations and assumptions

  • Ties choose the first endpoint under either policy. This does not calculate point-to-segment distance, inspect geometry or choose the nearest interior point.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Use the actual coordinates and intended metric when geometric distance is required. Preserve reference normalization and angular tie conventions in the full calculation; supplied endpoint distances or squared-norm residuals do not establish the underlying geometry.

References

  1. Calculation and input contract: distance/segment-endpoint-distance-choice — tool.io

Similar or alternative tools