Filter löschen
Filter löschen

distance between two vertices

5 Ansichten (letzte 30 Tage)
lina it
lina it am 19 Apr. 2012
How I can compute the distance between two vertices (point)
vertex1 = (x,y,z) vertex2 = (x,y,z)

Antworten (2)

Andrei Bobrov
Andrei Bobrov am 19 Apr. 2012
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 Kommentar
Jan
Jan am 19 Apr. 2012
Sometimes this is fast for row vectors: v = vertex1 - vertex2; d = sqrt(v * v');

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 19 Apr. 2012
Wouldn't the Pythagorean theorem or hypot() work?

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by