Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Function invertNdTransformForQuery

    • Inverse-transform slicePosition and tolerance from world space to local space.

      For affine (effective = scale * raw + offset): local_pos = (world_pos - offset) / scale local_tol = world_tol / |scale|

      For permutation: compute inverse permutation and remap the slice index. Tolerance is unchanged (categorical dims use integer matching).

      This allows querying the spatial index in local (stored) coordinates without transforming any point data — O(1) per dimension.

      A DISCRETE dimension's values live on the range[0] + k · step grid — that is the format's discrete contract, and the whole slicing stack leans on it: the navigation UI snaps slice targets to that grid, and the per-element MEMBERSHIP gates therefore use a half-step window (|value − target| ≤ 0.5 × step; see tolerance-computer.ts and effective-radius-calculator.ts), which selects exactly one category for an on-grid target.

      A non-unit affine nd_transform breaks that premise: an on-grid WORLD target inverts to an OFF-grid LOCAL target. scale: 2 at world T = 7 gives local 3.5, and the half-step window then admits local 3 AND local 4 — two neighbouring categories drawn at once, neither of which belongs to the requested world slice. At scale: 3, world T = 7 (local 2.333) silently admits local 2.

      The question is therefore not "is the inverse on the grid?" but the spec's own forward rule for discrete ordinals, effective = round(scale · original + offset) (docs/guides/specs/ND_TRANSFORMS_SPEC.md §4.1): does any local grid point map to the queried world value? Those two predicates coincide only for integer scale/offset. Testing inverse-on-grid instead would blank every slice of a node with, say, offset: 0.4 — for which round(k + 0.4) = k gives every world value a preimage — and §11.3 explicitly blesses fractional scale on discrete dims ("valid but lossy"), as does the Python validator.

      So resolveDiscretePreimage walks the local grid candidates bracketing the exact inverse and keeps the first whose forward image rounds to the queried world value. On success the local slice position is snapped to that candidate, which additionally makes the query exactly on-grid — so the downstream half-step window selects that one category and can no longer admit a neighbour at an exact midpoint. On failure the world value is the image of no local value and must display nothing; "nothing" cannot be encoded as a slice position, so it is reported out of band as noPreimage and the per-geometry range queries turn it into an empty range list, which every loader already renders as "cleared".

      Exempt: extend_to_all dimensions (named in extendDims — the dimension is not being sliced at all) and categorical permutations (a bijection always has exactly one preimage).

      KNOWN LIMITATION: the local grid is taken to be the dimension's declared range[0] anchor and step, which are WORLD-space quantities. For a unit-converting transform the local data may sit on a different grid, and there is no metadata describing it. This matches what the downstream membership window already assumes (it applies the same step as a LOCAL half-width), so the two stay consistent.

      Parameters

      • slicePosition: readonly number[]

        Current slice position in world (transformed) space

      • tolerance: readonly number[]

        Per-dimension tolerance in world space

      • ndTransform: NdTransformMap

        Composed world nD transform for this node

      • dimensions: readonly QueryDimensionInfo[]

        Per-dimension metadata (length = ndim). name is matched against ndTransform keys; discrete/step/range drive the no-preimage rule.

      • displayDims: readonly number[]

        Indices of displayed dimensions (to skip)

      • extendDims: readonly string[] = []

        The node's extend_to_all dimension NAMES. Authoritative exemption list: the tolerance sentinel is absent on every Lines path, so it cannot be inferred from tolerance alone.

      Returns { slicePosition: number[]; tolerance: number[]; noPreimage: boolean }

      New slicePosition (snapped to the resolved local grid point where a preimage exists) and tolerance in local (raw) space, plus noPreimage when the world slice has no local counterpart at all