Skip to content

docs: dt_mesh returns plain distance, not squared distance - #85

Merged
balbasty merged 2 commits into
mainfrom
docs/dt-mesh-plain-distance
Aug 19, 2026
Merged

docs: dt_mesh returns plain distance, not squared distance#85
balbasty merged 2 commits into
mainfrom
docs/dt-mesh-plain-distance

Conversation

@balbasty

Copy link
Copy Markdown
Collaborator

Closes#74.

include/fastfields/api/distance.h's doc comment for dt_mesh's dist
output said "Output tensor for squared distances". It is not squared.

Verified against the CPU suite, which is the source of truth for op
semantics: tests/lib-cpu/test_distance_mesh.cpp pins the output against
std::sqrt(point_tri_sqdist(...)) (line 182) and against
std::sqrt(best) for the brute-force reference (line 257) — i.e. the plain
Euclidean point-to-triangle distance, negated inside the surface when
_signed.

As the issue asks, the neighbours were checked while in there:

  • dt_spline_table / dt_spline_brent / dt_spline_gaussnewton say
    "best squared distance" and are correct — their reference in
    tests/lib-cpu/test_distance_spline.cpp accumulates an unrooted squared
    distance. Left alone.
  • dt_euclidean / dt_l1 are in-place and document no output parameter,
    so there is nothing to drift. Left alone.

Doc-only: no code, no behaviour change. Only codespell and the
changed-lines clang-format job are triggered by this path.


Generated by Claude Code

`api/distance.h`'s doc comment for `dt_mesh`'s `dist` output claimed
"squared distances". It does not: the CPU suite pins the output against
`std::sqrt(point_tri_sqdist(...))` (tests/lib-cpu/test_distance_mesh.cpp),
i.e. the plain Euclidean point-to-triangle distance, signed when `_signed`.
The neighbouring `dt_spline_*` docstrings say "best squared distance" and
are correct -- their reference in tests/lib-cpu/test_distance_spline.cpp is
an unrooted squared distance -- so only `dt_mesh` is corrected here.
`dt_euclidean` / `dt_l1` document no output param at all (they are
in-place) and are untouched.
Doc-only; no behaviour change.
Closes#74
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016AjQcY78NgbagPSbPJRr6Z
@balbasty
balbastyforce-pushed the docs/dt-mesh-plain-distance branch from 621db86 to 4975867CompareAugust 19, 2026 19:12
The `lint (clang-format, changed lines)` job failed on this branch. The
cause is not the new text: `@param _signed` (81 cols) and `@param naive`
(90 cols) predate this change, and clang-format reflows the whole doc block
once any line inside it is touched, so it proposed breaking those two at
column 80 with continuations starting at ` * `.
Wrapping them by hand instead keeps the block's hanging-indent alignment and
leaves clang-format with nothing to change (`git clang-format main` is now
clean on this branch). Still doc-only.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016AjQcY78NgbagPSbPJRr6Z
@balbasty
balbasty merged commit 9bf26dc into mainAug 19, 2026
11 checks passed
@balbasty
balbasty deleted the docs/dt-mesh-plain-distance branch August 19, 2026 23:09
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

distance.h: dt_mesh docstring claims squared distance, but it returns plain distance

2 participants

@balbasty@claude