swarm-modeling
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: measuring distance in grids


From: Joshua O'Madadhain
Subject: Re: measuring distance in grids
Date: Fri, 11 Jan 2002 12:23:08 -0800 (Pacific Standard Time)

On Fri, 11 Jan 2002, Paul E Johnson wrote:

> I have a project where agents are in a grid and it is important to 
> measure distance.  The authors of the original article I'm replicating 
> do not define a distance metric, but I originally assumed the distance 
> was Euclidean. That is, I guessed the distance between x=(x1,x2) and 
> y=(y1,y2) would be measured
> 
> dist = sqrt[ (x1-y1)*(x1-y1)+(x2-y2)*(x2-y2) ]
> 
> but I get some funny results using that, 

When you say "funny results", do you mean that the results are
inconsistent with those of the original article, or inconsistent with what
you expected to see?  If the latter, how do the results that you expected
to see differ from what you got?

> and I'm starting to wonder what 
> other metrics people might think are standard on a rectangular grid.

> One I'm considering is "radial square" distance, where distance is the 
> radius of the square centered on a point that touches another point. 
> That means the distance from a cell to all immediate Moore neighbors is 
> 1, and for the next larger neighborhood, the distance would be 2. See 
> what I mean?  Here, the distance from the center point 0 to a neighbor is:
>             3333333
>             3222223
>             3211123
>             3210123
>             3211123
>             3222223
>             3333333

There are a number of different metrics that might be used; which is
appropriate will depend on what you want "distance" to mean.  For example,
if your agents move rectilinearly, and you want "distance" to mean the
length of the shortest path between two grid locations, then the Manhattan
metric ( d(x,y) = |x1 - y1| + |x2 - y2| ) would be most appropriate.  
Your "radial square" distance, similarly, would be most appropriate if
your agents could also move diagonally.

PS: One possibility to consider is that your current metric may be
misbehaving if you've swapped coordinates (i.e., if your points are
actually (x1, y1) and (x2, y2) instead of (x1, x2) and (y1, y2)).  It's
an easy mistake to make.

Regards,

Joshua O'Madadhain

 address@hidden Per Obscurius...www.ics.uci.edu/~jmadden
    Joshua Madden: Information Scientist, Musician, Philosopher-At-Tall
 It's that moment of dawning comprehension that I live for--Bill Watterson
My opinions are too rational and insightful to be those of any organization.





                  ==================================
   Swarm-Modelling is for discussion of Simulation and Modelling techniques
   esp. using Swarm.  For list administration needs (esp. [un]subscribing),
   please send a message to <address@hidden> with "help" in the
   body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]