ポイントからポイントまでの距離: dist = sqrt(dx * dx + dy * dy); しかし、sqrt は遅すぎて受け入れられません。本の 2 点の距離を推定するために、Taylor McLaughlin Series という方法を見つけました。しかし、次のコードが理解できません。私を助けてくれてありがとう。
#define MIN(a, b) ((a < b) ? a : b)
int FastDistance2D(int x, int y)
{
// This function computes the distance from 0,0 to x,y with 3.5% error
// First compute the absolute value of x, y
x = abs(x);
y = abs(y);
// Compute the minimum of x, y
int mn = MIN(x, y);
// Return the distance
return x + y - (mn >> 1) - (mn >> 2) + (mn >> 4);
}
McLaughlin Series に関する関連データを参照しましたが、戻り値が McLaughlin Series を使用して値を推定する方法をまだ理解できません。みんなありがとう〜