LSST Applications
21.0.0157ge5427992+ebd5a6ff45,22.0.0+000ed19a8b,22.0.0+06dd0f93dc,22.0.0+4b7a2a553d,22.0.0+b6433cb9cd,22.0.0+dfc68d4d09,22.0.0+e6ee2fa291,22.0.11g7d6de66+d5b52a074f,22.0.11g87000a6+2036d5eaca,22.0.11g8e32f31+e6ee2fa291,22.0.113g5845b92+f6aee3ecd9,22.0.114g6272d78+53053d8c6e,22.0.12g92698f7+000ed19a8b,22.0.12ga9b0f51+dfc68d4d09,22.0.121g5bd0cb7e+70d022058a,22.0.122g41e933f+f35f853512,22.0.123ged5e717+d5b52a074f,22.0.124g4fd6b65+3f3650e748,22.0.128g0aba325f+8c51f084bf,22.0.13g59f966b+51be954097,22.0.13g849a1b8+34b059fcac,22.0.13g85f6b2a+dfc68d4d09,22.0.13geb91c39+d5b52a074f,22.0.136g99137b0eb+ec953d57b4,22.0.14g243d05b+407143e2a6,22.0.14g35e927a+600e1785c4,22.0.14gf0e1808+40b33593de,22.0.15g096abc9+fb28b9dcc5,22.0.15g15c806e+7e58257bcf,22.0.15g75bb458+2e8da71d76,22.0.15gec4f438+6eccae7d65,22.0.17gba73697+7e58257bcf,22.0.18g903eb1c+d5b52a074f,masterg6e05de7fdc+bdf610cf3e,masterg99da0e417a+4b7a2a553d,w.2021.43
LSST Data Management Base Package

Q3C is described by the following paper:
Koposov, S., Bartunov, O., Jul. 2006. Q3C, Quad Tree Cube – The new skyindexing concept for huge astronomical catalogues and its realization for main astronomical queries (cone search and xmatch) in Open Source Database PostgreSQL. In: Gabriel, C., Arviset, C., Ponz, D., Enrique, S. (Eds.), Astronomical Data Analysis Software and Systems XV. Vol. 351 of Astronomical Society of the Pacific Conference Series. p. 735.
available online here. The authors also provide an implementation.
Two kinds of Q3C indexes can be produced by this library. The first kind, "original" Q3C indexes, are compatible with those produced by the Q3C PostgreSQL extension, and are provided by the Q3cPixelization class.
The second kind, "modified" Q3C indexes, are produced according to a similar scheme described below. They are provided by the Mq3cPixelization class.
To obtain the index of unit vector P, both the original and modified schemes start by centrally projecting P onto the faces of the cube [1,1]³. Each of the 6 cube faces is assigned a distinct face number, and a local coordinate system (u, v). A grid of pixels is overlaid on each cube face, and pixels are labeled according to a space filling curve. The index is obtained by combining the label of the pixel containing the face coordinates with the face number.
In the original Q3C scheme, the cube faces are numbered 05, where:
Face coordinates (u, v) are converted to grid coordinates (s, t) using a linear transformation. Grid coordinates s and t are both in [0, n), where n = 2ᵐ is the Q3C grid resolution. The Q3C index is formed by concatenating the 3 bit face number and the 2m bit Morton index of (s,t).
In the modified scheme, cube faces are numbered 1015, where:
The transformation to grid coordinates (s, t), where s and t are both in [0, n) and n = 2ᵐ is the grid resolution, is nonlinear.
The reason is that if each cube face is overlaid with a uniform grid (as in the original Q3C scheme), then the area of grid pixels (projected back onto the sphere) varies by a factor of about 5.2. The largest pixels are in the face centers (where the face is tangent to the unit sphere), and the smallest are in the face corners.
To get more uniform pixel area, we use an idea from the Google S2 library. In particular, we apply a separable transformation to face coordinates before the linear transformation to grid coordinates. This allows pixel area to be adjusted by changing edge spacing. Edges remain geodesic, so that pixels are convex spherical polygons as in the original scheme.
One suitable transformation is obtained by noticing that the central projection of (z, x) = (cos θ, sin θ), where π/4 ≤ θ ≤ π/4, onto the line z = 1 is (1, tan θ) (taking the origin as the center of projection). So, applying f(x) = 4 arctan x / π to each face coordinate will produce pixel edges that subtend more uniform angles. This reduces pixel area variation down to a factor of about 1.414.
However, computing arctangents is relatively expensive. Instead, the modified Q3C scheme applies f(x) = x(4  x)/3, a decent quadratic approximation to 4 arctan x / π, to both u and v before applying a linear transformation to grid coordinates (s, t). This cuts area variation down to a factor of about 1.56. f(x) was arrived at by picking a quadratic polynomial satisfying f(0) = 0 and f(1) = 1 with coefficients close to the best minimax rational approximation of degree 2 for 4 arctan x / π on the interval [0, 1]:
0.00312224879 + (1.357648680  0.3514041823 x) x
(computed with Maple using the Remez algorithm). The constraint f(x) = f(x) (following the symmetry of arctan) is used to extend the domain to [1, 1]. Though better approximations likely exist, this one is already noticeably better than the one used by the S2 library, which results in a pixel area variation factor of about 2.1. Note that S2 employs a quadratic approximation for tan rather than arctan, which means that grid to face coordinate conversion is faster since it does not involve any square roots  this may have been more important to the S2 authors than pixel area variation.
Finally, the modified Q3C index I of a point P is formed by concatenating the 4 bit face number of P with the 2m bit Hilbert index of its grid coordinates (s, t). The Hilbert curve is preferred over the Morton curve used in the original scheme because it has better spatial locality  see:
Analysis of the Clustering Properties of the Hilbert SpaceFilling Curve Moon, B., Jagadish, H. V., Faloutsos, C., & Saltz, J. H. IEEE Trans. on Knowledge and Data Engineering, vol. 13, no. 1, pp. 124141, 2001
for an analysis. Because the MSB of the face number is always 1, the grid resolution is derivable from the index of the MSB of I.