shortest distance between two points

hi All,
I am trying to calculate a shortest distance between two points.
lets say, an object moved from coordinates (3,4) to ( 7,7).
then distance between these two points can be calculated using simple pythagoras theoram
d=(7-3)^2 + (7-4)^2= 5
I am also trying to calculate shortes distance between these two coordiantes.
if I am trying ds= (7-3)+(7-4)= 7
but ds can not a displacement, as displacement is the shortest distance between two points.
any one can help please?

 채택된 답변

Matt J
Matt J 2012년 10월 2일

0 개 추천

d=norm([7,7]-[3,4])
ds=norm([7,7]-[3,4],1)

댓글 수: 3

mohammad Farhan
mohammad Farhan 2012년 10월 2일
Thanks Matt, for your response.
let me share here a complete problem.
my data is being packed in a matrix.
e.g.
cX=fb.data.cX; cY=fb.data.cY;
% % distance travelled between each frame dX=diff(cX); dY=diff(cY); adX=abs(dX); adY=abs(dY); a=adX.^2; b=adY.^2;
% use pythagoras CS=plus(a,b); Cq=sqrt(CS); % % % calculate total distance travelled in full box unit (=cm in 1cm box chamber) totaldistance=sum(Cq);
if what I have calculated is the distance travelled, then how should I calculate the displacement and total displacement using X and Y coordinates?
Your help will be really appreciated
Matt J
Matt J 2012년 10월 2일
Isn't it adX+adY? If not, I need we'll need a better example of what you want.
mohammad Farhan
mohammad Farhan 2012년 10월 4일
Yes you are right, but I just realised that using pythagoras theroam I was allready calculating displacement or shortest distance between two point. Using adX+adY will give me actual distance travelled.
Thanks for your input Matt.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by