필터 지우기
필터 지우기

distance between two vertices

조회 수: 5 (최근 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 CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by