angulardistance

This IDL facility computes the angular distance (in RADIANS) between pairs of vectors.

Location in HEALPix directory tree: src/idl/toolkit/angulardistance.pro 


FORMAT

IDL> distance=angulardistance(V, W, [/HELP])


QUALIFIERS

V
3D-vector (of shape (3) or (1,3)) or list of n 3D-vectors (of shape (n,3))
W
3D-vector (of shape (3) or (1,3)) or list of n 3D-vectors (of shape (n,3))
It is not necessary for V and W vectors to be normalised to 1 upon calling the function.
If V and W both are lists of vectors, they should be of the same length.
If V (and/or W) has the form (n,3,4) (like the pixel corners returned by pix2vec_*), it should be preprocessed with V = reform( transpose(V, [0,2,1]), n_elements(V)/3, 3) to take the form (n*4,3) before being passed to angulardistance.


KEYWORDS

/HELP
if set, prints out the help header and exits


DESCRIPTION

After renormalizing the vectors, angulardistance computes the angular distance using $\cos^{-1}(\ensuremath{\textbf{V}}.\ensuremath{\textbf{W}})$ in general, or $2 \sin^{-1}\left(\vert\vert\ensuremath{\textbf{V}}-\ensuremath{\textbf{W}}\vert\vert/2\right)$ when $\ensuremath{\textbf{V}}$ and $\ensuremath{\textbf{W}}$ are almost aligned.
If $\ensuremath{\textbf{V}}$ (resp. $\ensuremath{\textbf{W}}$) is a single vector, while $\ensuremath{\textbf{W}}$ (resp. $\ensuremath{\textbf{V}}$) is a list of vectors, then the result is a list of distances $d_i = \mathrm{dist}(\ensuremath{\textbf{V}},{\ensuremath{\textbf{W}}}_i)$ (resp. $d_i = \mathrm{dist}({\ensuremath{\textbf{V}}}_i,{\ensuremath{\textbf{W}}})$).
If both $\ensuremath{\textbf{V}}$ and $\ensuremath{\textbf{W}}$ are lists of vector of the same length, then the result is a list of distances $d_i = \mathrm{dist}({\ensuremath{\textbf{V}}}_i,{\ensuremath{\textbf{W}}}_i)$.


RELATED ROUTINES

This section lists the routines related to angulardistance

idl
version 6.4 or more is necessary to run angulardistance.


EXAMPLE:

nside=8
pix2vec_ring, nside, lindgen(nside2npix(nside)), vpix
mollview, angulardistance( vpix, [1,1,1])
will plot the angular distance between the Healpix pixels center for Nside=8 , and the vector $(x,y,z) = (1,1,1)/\sqrt{3}$

Version 3.82, 2022-07-28