平方根を使わずに距離を求める のバックアップ差分(No.1)

更新


  • 追加された行はこの色です。
  • 削除された行はこの色です。
[[公開メモ]]

* 平面状の2点間の距離を平方根を使わずに計算する [#v08053c6]

http://d.hatena.ne.jp/nowokay/20120604

twitter にてこちらの記事を知り、少し調べてみました。

* Mathematica で確かめる [#y6b0a391]

正確な距離関数はこう:

&math(d_\mathrm{sqrt}=\sqrt{x^2+y^2});

 LANG:Mathematica
 distance[x_, y_] := Sqrt[x^2 + y^2]
 Plot3D[distance[x, y], {x, -1, 1}, {y, -1, 1}, ImageSize -> Large]

&attachref;

最大値、最小値を利用した近似はこう&math((a=1007/1024, b=441/1024));:

&math(d_\mathrm{max,min}=a\mathrm{max}(|x|,|y|)+b\mathrm{min}(|x|,|y|));

 LANG:Mathematica
 distance2[x_, y_, a_, b_] := a Max[Abs[x], Abs[y]] + b Min[Abs[x], Abs[y]]
 Plot3D[distance2[x, y, 1007/1024, 441/1024], {x, -1, 1}, {y, -1, 1}, ImageSize -> Large]

&attachref;


Counter: 14709 (from 2010/06/03), today: 1, yesterday: 0