2点間の距離

#include <math.h>

/**
* 2点間の距離
*
* @return 座標1と座標2の間の距離
*
* @param point1 座標1
* @param point2 座標2
*
* http://frog.raindrop.jp/knowledge/archives/001607.html
*/
static double calcDistance( const POINT& point1, const POINT& point2 )
{
// 変位
double dx = /*abs*/( point2.x - point1.x );
double dy = /*abs*/( point2.y - point1.y );

// 平方根
// sqrt( ( dx * dx ) + ( dy * dy ) );
return sqrt( pow( dx, 2.0 ) + pow( dy, 2.0 ) );
}
最終更新:2009年04月03日 14:15
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。