distance between two vertices

3 ビュー (過去 30 日間)
lina it
lina it 2012 年 4 月 19 日
How I can compute the distance between two vertices (point)
vertex1 = (x,y,z) vertex2 = (x,y,z)

回答 (2 件)

Andrei Bobrov
Andrei Bobrov 2012 年 4 月 19 日
Pythagorean
d = sqrt(sum((vertex1-vertex2).^2))
hypot()
k = vertex1-vertex2;
d = hypot(hypot(k(1),k(2)),k(3));
use norm()
d = norm(vertex1-vertex2,2);
use dist from Neural Network Toolbox
d = dist([vertex1;vertex2]')
use pdist from Statistics Toolbox
d = pdist([vertex1;vertex2])
  1 件のコメント
Jan
Jan 2012 年 4 月 19 日
Sometimes this is fast for row vectors: v = vertex1 - vertex2; d = sqrt(v * v');

サインインしてコメントする。


Image Analyst
Image Analyst 2012 年 4 月 19 日
Wouldn't the Pythagorean theorem or hypot() work?

カテゴリ

Help Center および File ExchangeConstruction についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by