comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Problem with dist function in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Problem with dist function in IDL [message #55305 is a reply to message #55301] Wed, 15 August 2007 17:34 Go to previous messageGo to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
> Useful, but not sufficient in my case :-(
> In the case of dist(4,1), say, how do you get the values 0.00, 1.00,
> 2.00, 1.00 ?
>
> Never quite got it! :-(
>
> G

Here is a graphical explanation of Mike's answer:

so, let's create an empty row of size 4

[a,b,c,d]

then we want to compute the distance from the top left corner to every
other cell, what the "dist" function does. To do that, let's assume we
have an infinite array: ....,c,d,a,b,c,d,a,b, .....
Then the we can see that from A to B, there is 1 cell (pixel, unit,
whatever), from A to C there is 2 cells and from A to D we have either 1
cell (because the beginning of the array is next to the last element of
it), or 3 cells (through B and C). Dist() will return the smallest
one... so you have dist(4,1) = 0,1,2,1

Now let's make it a tad bigger:
dist(10,10)
The last entry of the array is 1.41. From the first element, one has to
jump UP one cell to get to the last row, and LEFT one cell to get to the
last column... the distance is therefore 1.41

...
jean
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: controlling widget layout
Next Topic: xyouts for iPlot?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 17 10:48:51 PDT 2025

Total time taken to generate the page: 0.74751 seconds