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 ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by