Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1997
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Table of euclidean distances...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg7921] Table of euclidean distances...
  • From: "Joel Bock" <jbock at INETWORLD.NET>
  • Date: Mon, 21 Jul 1997 03:22:11 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Hello MathGroup:

I'm trying to create a table of euclidean distances between coordinates of
source and field points in 3-space for an acoustics simulation.  What I
have
done is both grossly brute-force and interminably long-running for large
numbers
of points.  There has to be a better way!  Can anyone suggest a better way
to do
this calculation, say, operating on vectors of points as opposed to one
element
at a time?  Given two tables, "src" and "fld", comprised of elements that
each
have three Cartesian coordinates: e.g., src[[i]] = { x[[i]], y[[i]], z[[i]
}, etc.  Then 
the distance function is

eucDist[x1_,x2_]:=Sqrt[ (x1[[1]]-x2[[1]])^2 + (x1[[2]]-x2[[2]])^2 +
(x1[[3]]-x2[[3]])^2  ];

and the calculation of the table of distances is

R=Table[ eucDist[ src[[i]], fld[[j]] ], {i,nSrc}, {j,nFld} ];

This works, but is inefficient.  For scatterers placed in the radiation
field of
the sources, things grind to a halt, as the scatterers have finite physical

dimension and therefore require 2 subscripts- one index for scatterer ID,
and the other for each "face" created to discretize the surface.  I am
observing the familiar "swapping orgy" phenomenon running this on a
486DX2 with 16 MB memory.  Buying a new computer is not an option for
me at present...
Any suggestions or example notebooks to speed this type of calculation 
up would be very welcome.  Thanks!




  • Prev by Date: Re: More on Positive[x]
  • Next by Date: Re: Replace expressions
  • Previous by thread: Re: More on Positive[x]
  • Next by thread: Re: Table of euclidean distances...