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 #55301] Thu, 16 August 2007 03:13 Go to previous message
Paolo Grigis is currently offline  Paolo Grigis
Messages: 171
Registered: December 2003
Senior Member
Gianguido Cianci wrote:
>> A graphical representation is also always useful...
>>
>> loadct,5
>> tvscl,shift(dist(512,512),256,256)
>>
>> Ciao,
>> Paolo
>
>
> 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
>

This program (not optimized) reproduces the functionality of DIST:

---------------------

n=4
m=5

a=dist(n,m)
b=fltarr(n,m)

FOR i=0L,n-1 DO BEGIN
FOR j=0L,m-1 DO BEGIN
i2=min([i,n-i])
j2=min([j,m-j])
b[i,j]=sqrt(i2^2+j2^2)
ENDFOR
ENDFOR


------------------

So dist[i,j] is the shortest distance from the euclidean
point with coordinates (i,j) to one of the points (0,0),
(0,m), (n,0) or (n,m).

Ciao,
Paolo
[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: Wed Oct 08 18:52:14 PDT 2025

Total time taken to generate the page: 0.00447 seconds