Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
境界条件が周期的である場合に、2点間のユークリッド距離をチェックするための最良の方法は何ですか?最小の距離と(範囲-距離)を試してみましたが、プログラムの構成方法が原因で、奇妙な出力が得られていると思います。残りの関数を再評価するのではなく、これにアプローチする別の良い方法が採用できることを望んでいます。
これはPythonのところでです。現在、numpy.linalg.normでユークリッド距離を見つけていますが、私が推測するのと同じことを行うSciPypdistルーチンがあります。
dxとrange-dxの間で小さいものについては、各ディメンションで個別に確認する必要があります。
def distance(p1, p2): total = 0 for i, (a, b) in enumerate(zip(p1, p2)): delta = abs(b - a) if delta > dimension[i] - delta: delta = dimension[i] - delta total += delta ** 2 return total ** 0.5