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

Home » Public Forums » archive » Re: the fastest way to find number of points in sphere(radius r)
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: the fastest way to find number of points in sphere(radius r) [message #46413 is a reply to message #46411] Tue, 22 November 2005 04:16 Go to previous messageGo to previous message
Xavier Llobet is currently offline  Xavier Llobet
Messages: 7
Registered: April 2005
Junior Member
In article <1132659183.873193.230050@g44g2000cwa.googlegroups.com>,
"PYJ" <snfinder@naver.com> wrote:

> Data-------------------------------------------------------- ---------------
> lots of points: X, Y, Z
> lots of spheres: XC, YC, ZC (positions of center), R(radius)
> ------------------------------------------------------------ ------------------
>
> I want to know the number of galaxies inside each sphere without a
> loop.(If it is possible)
> The faster, the better!
>
> Help me, experts~~!!!

I have the nagging feeling of doing someone's homework...

A way to do what you want:

ix=indgen(n_elements(X)) ; index array to be used in BLAS_AXPY
t=transpose([[X], [Y], [Z]]) ; array(3,n) of cartesian coordinates

;Loop over spheres' centers:
t1=t ; temporary array

; Shift points' coordinates to the j-th sphere's center
blas_axpy, t1, -1, [XC(j), YC(j), ZC(j)], 1, [0,0], 2, ix

; Convert to spherical coordinates (long, lat, radius)
sph = cv_coord(from_rect=t1, /TO_SPHERE)

; So sph(2,*) is the array of distances.
; Histogram it, or treat as you please.

;end_loop


It could be faster than your method...

--
_xavier
--
Only one "o" in my e-mail address
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: image display with different pixel size in x & y
Next Topic: Re: 3d space set up and plotting data on maps

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

Current Time: Sun Oct 12 10:04:58 PDT 2025

Total time taken to generate the page: 1.04216 seconds