I have two vectors like
int main(int argc, char *argv())
{
.........
Vector3f center(0.4,0.1,0.3) ;
Vector3f point(0.1,0.2,0.7);
.......
}
How can I calculate Manhattan distance using eigen library? I am using VS2010.
This isn't hard as long as you know what Manhattan distance is (though I haven't seen the term used for 3D vectors before) - just have a look in the Eigen API doc for the relevant functions, you'll then find that the following works:
Vector3f center(0.4,0.1,0.3) ;
Vector3f point(0.1,0.2,0.7);
Vector3f diff = center - point;
float manh_dist = diff.cwiseAbs().sum();
別の方法は、マンハッタン距離が、次のような一般的なlpNorm法を使用して取得できるL1ノルムに対応することを確認することです。
manh_dist = (center-point).lpNorm<1>();
このページを参照してください。