Skip to content

Main content

Periodic Box Wrap One Axis Tool

Calculate periodic box wrap one axis from explicit caller-supplied inputs.

Loading tool…

Description

Wrap a coordinate into a declared periodic box and return its image index.

A periodic coordinate identifies values separated by a whole cycle. Minimum-image gaps require a wrapping interval and an explicit half-cycle tie convention; signed direction and unsigned separation answer different questions.

Wrap a coordinate into a declared periodic box and return its image index.

When to use this tool

Use Periodic Box Wrap One Axis when checking one explicit periodic-coordinate or gap convention.

How to use the tool and how it works

  1. Enter coordinate, origin, length. 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 coordinate, image. Use the output convention below.

Wrap a coordinate into a declared periodic box and return its image index. Require length > 0; image = floor((coordinate-origin)/length), while the output coordinate uses the nonnegative modulo within that box.1

Input fieldMeaning and unitsAccepted input
coordinateCoordinateRequired. Finite number.
originOriginRequired. Finite number.
lengthLengthRequired. Finite number; strictly above 0.
Output fieldInterpretationReturned shape
coordinateCoordinateRequired. Finite number.
imageSigned whole wrapping index floor((input coordinate-origin)/length).Required. Safe integer.
json
{
  "input": {
    "coordinate": -2,
    "origin": 0,
    "length": 10
  },
  "output": {
    "coordinate": 8,
    "image": -1
  }
}

Limitations and assumptions

  • Image indexes can be negative; input and origin must share a coordinate basis.
  • 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 a complete periodic geometry model when multiple axes, seam-crossing intervals or path winding matter.

References

  1. Calculation and input contract: distance/periodic-box-wrap-one-axis — tool.io

Similar or alternative tools