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.
我有两个向量
int main(int argc, char *argv()) { ......... Vector3f center(0.4,0.1,0.3) ; Vector3f point(0.1,0.2,0.7); ....... }
如何使用特征库计算曼哈顿距离?我正在使用VS2010。
只要您知道曼哈顿距离是多少,这并不难(尽管我以前没有见过用于 3D 向量的术语)——只需查看 Eigen API 文档中的相关函数,您就会发现以下作品:
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>();
请参阅此页面以供参考。