Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • $\begingroup$ Note: Compile optimizes code, so this circDist = Compile[{{t1, _Real}, {t2, _Real}}, With[{d = Abs[t1 - t2]}, Min[{d, 1 - d}]]] is a little faster. $\endgroup$ Commented Jun 9, 2025 at 6:40
  • $\begingroup$ Thank you, but Last@midpoint[{0.9,0.1}] is 0.9, but it's obviously 0 or 1 $\endgroup$ Commented Jun 9, 2025 at 7:32
  • 2
    $\begingroup$ @CraigCarter I think midpoint[{t1_, t2_}] := With[{dist = Abs[t1 - t2]}, Which[dist <= 1 - dist, {dist, Mean[{t1, t2}]}, True, {1 - dist, Mean[{t1, t2}] + 1/2}]] is the correct way. It fullfills Last@midpoint[{0.9,0.1}]==1 as lesobrod mentions. $\endgroup$ Commented Jun 9, 2025 at 8:00