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?

 Risposta accettata

Matt J
Matt J il 2 Ott 2012

0 voti

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

3 Commenti

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
Isn't it adX+adY? If not, I need we'll need a better example of what you want.
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Graph and Network Algorithms in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by