29#include "hipsmanager.h"
31#include "kstarsdata.h"
32#include "geolocation.h"
34static const double twothird = 2.0 / 3.0;
35static const double twopi = 6.283185307179586476925286766559005768394;
36static const double inv_halfpi = 0.6366197723675813430755350534900574;
38static const int jrll[] = { 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4 };
39static const int jpll[] = { 1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7 };
41static const short ctab[] =
43#define Z(a) a,a+1,a+256,a+257
44#define Y(a) Z(a),Z(a+2),Z(a+512),Z(a+514)
45#define X(a) Y(a),Y(a+4),Y(a+1024),Y(a+1028)
46 X(0), X(8), X(2048), X(2056)
52static const short utab[] =
54#define Z(a) 0x##a##0, 0x##a##1, 0x##a##4, 0x##a##5
55#define Y(a) Z(a##0), Z(a##1), Z(a##4), Z(a##5)
56#define X(a) Y(a##0), Y(a##1), Y(a##4), Y(a##5)
57 X(0), X(1), X(4), X(5)
63static short xoffset[] = { -1, -1, 0, 1, 1, 1, 0, -1 };
64static short yoffset[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
66static short facearray[9][12] =
68 { 8, 9, 10, 11, -1, -1, -1, -1, 10, 11, 8, 9 },
69 { 5, 6, 7, 4, 8, 9, 10, 11, 9, 10, 11, 8 },
70 { -1, -1, -1, -1, 5, 6, 7, 4, -1, -1, -1, -1 },
71 { 4, 5, 6, 7, 11, 8, 9, 10, 11, 8, 9, 10 },
72 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 },
73 { 1, 2, 3, 0, 0, 1, 2, 3, 5, 6, 7, 4 },
74 { -1, -1, -1, -1, 7, 4, 5, 6, -1, -1, -1, -1 },
75 { 3, 0, 1, 2, 3, 0, 1, 2, 4, 5, 6, 7 },
76 { 2, 3, 0, 1, -1, -1, -1, -1, 0, 1, 2, 3 }
79static uchar swaparray[9][12] =
92static double fmodulo(
double v1,
double v2)
111 boundaries(
nside, pix, 1, v);
114 for (
int i = 0; i < 4; i++)
116 transformed[i].
setX(v[i].x());
117 transformed[i].
setY(v[i].y());
118 transformed[i].
setZ(v[i].z());
120 double ra = 0,
de = 0;
121 xyz2sph(transformed[i], ra,
de);
125 if (HIPSManager::Instance()->getCurrentFrame() == HIPSManager::HIPS_GALACTIC_FRAME)
140 skyCoords[i].updateCoords(KStarsData::Instance()->updateNum(),
false);
141 skyCoords[i].EquatorialToHorizontal(KStarsData::Instance()->lst(), KStarsData::Instance()->
geo()->lat());
154 double yc = (
iy + 0.5) /
nside;
155 double d = 1. / (step *
nside);
157 for (
int i = 0; i < step; ++i)
168 double jr = jrll[face] -
fx -
fy;
201 locz = (2 -
jr) * 2. / 3.;
225 raw = (pix & 0x5555) | ((pix & 0x55550000) >> 15);
226 *
ix = ctab[
raw & 0xff] | (ctab[
raw >> 8] << 4);
228 raw = (pix & 0x5555) | ((pix & 0x55550000) >> 15);
229 *
iy = ctab[
raw & 0xff] | (ctab[
raw >> 8] << 4);
232static int64_t spread_bits64 (
int v)
234 return (int64_t)(utab[ v & 0xff])
235 | ((int64_t)(utab[(v >> 8) & 0xff]) << 16)
236 | ((int64_t)(utab[(v >> 16) & 0xff]) << 32)
237 | ((int64_t)(utab[(v >> 24) & 0xff]) << 48);
244 (utab[
ix & 0xff] | (utab[
ix >> 8] << 16)
245 | (utab[
iy & 0xff] << 1) | (utab[
iy >> 8] << 17));
270static int nside2order(qint32
nside)
274 while((
nside >> (++i)) > 0);
291void HEALPix::neighbours(
int nside, qint32
ipix,
int *result)
295 int order = nside2order(
nside);
303 px0 = spread_bits64(
ix ),
py0 = spread_bits64(
iy ) << 1,
304 pxp = spread_bits64(
ix + 1),
pyp = spread_bits64(
iy + 1) << 1,
305 pxm = spread_bits64(
ix - 1),
pym = spread_bits64(
iy - 1) << 1;
318 for (
int i = 0; i < 8; ++i)
320 int x =
ix + xoffset[i];
321 int y =
iy + yoffset[i];
349 if ((bits & 1) > 0) x = (int)(
nside - x - 1);
350 if ((bits & 2) > 0) y = (
int)(
nside - y - 1);
357 result[i] = xyf2nest(
nside, x, y, f);
365int HEALPix::ang2pix_nest_z_phi (qint32
nside_,
double z,
double phi)
368 double tt = fmodulo(
phi, twopi) * inv_halfpi;
392 jp = (int)(tp *
tmp);
393 jm = (int)((1.0 - tp) *
tmp);
413int HEALPix::getPix(
int level,
double ra,
double dec)
416 double polar[2] = { 0, 0 };
418 if (HIPSManager::Instance()->getCurrentFrame() == HIPSManager::HIPS_GALACTIC_FRAME)
420 static QMatrix4x4 gl(-0.0548762f, -0.873437f, -0.483835f, 0,
421 0.4941100f, -0.444830f, 0.746982f, 0,
422 -0.8676660f, -0.198076f, 0.455984f, 0,
425 double rcb = cos(dec);
440void HEALPix::getPixChilds(
int pix,
int *
childs)
448void HEALPix::xyz2sph(
const QVector3D &
vec,
double &l,
double &b)
455 l -= floor(l / (M_PI * 2)) * (M_PI * 2);
467 b = (
vec.z() > 0.0) ? M_PI / 2. : -
dms::PI / 2.;
The sky coordinates of a point in the sky.
An angle, stored as degrees, but expressible in many ways.
static constexpr double DegToRad
DegToRad is a const static member equal to the number of radians in one degree (dms::PI/180....
KGUIADDONS_EXPORT QColor tint(const QColor &base, const QColor &color, qreal amount=0.3)
GeoCoordinates geo(const QVariant &location)
QStringView level(QStringView ifopt)
QTextStream & dec(QTextStream &stream)