| 1 |
/* |
| 2 |
# This file is part of the Astrometry.net suite. |
| 3 |
# Licensed under a 3-clause BSD style license - see LICENSE |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef STARUTIL_H |
| 7 |
#define STARUTIL_H |
| 8 |
|
| 9 |
#include <math.h> |
| 10 |
#include "an-bool.h" |
| 11 |
#include "keywords.h" |
| 12 |
|
| 13 |
#define DIM_STARS 3 |
| 14 |
#define DIM_XY 2 |
| 15 |
|
| 16 |
// upper bound of dimquads value |
| 17 |
#define DQMAX 5 |
| 18 |
// upper bound of dimcodes value |
| 19 |
#define DCMAX 6 |
| 20 |
|
| 21 |
InlineDeclare int dimquad2dimcode(int dimquad); |
| 22 |
|
| 23 |
typedef unsigned char uchar; |
| 24 |
|
| 25 |
#define ONE_OVER_SIXTY 0.016666666666666666 |
| 26 |
|
| 27 |
// pi / 180. |
| 28 |
#define RAD_PER_DEG 0.017453292519943295 |
| 29 |
// pi / (180. * 60.) |
| 30 |
#define RAD_PER_ARCMIN 0.00029088820866572158 |
| 31 |
// pi / (180. * 60. * 60.) |
| 32 |
#define RAD_PER_ARCSEC 4.8481368110953598e-06 |
| 33 |
|
| 34 |
// 180. / pi |
| 35 |
#define DEG_PER_RAD 57.295779513082323 |
| 36 |
#define DEG_PER_ARCMIN ONE_OVER_SIXTY |
| 37 |
// 1./3600. |
| 38 |
#define DEG_PER_ARCSEC 0.00027777777777777778 |
| 39 |
|
| 40 |
// 60. * 180. / pi |
| 41 |
#define ARCMIN_PER_RAD 3437.7467707849396 |
| 42 |
#define ARCMIN_PER_DEG 60.0 |
| 43 |
#define ARCMIN_PER_ARCSEC ONE_OVER_SIXTY |
| 44 |
|
| 45 |
// 60. * 60. * 180. / pi |
| 46 |
#define ARCSEC_PER_RAD 206264.80624709636 |
| 47 |
#define ARCSEC_PER_DEG 3600.0 |
| 48 |
#define ARCSEC_PER_ARCMIN 60.0 |
| 49 |
|
| 50 |
InlineDeclare Const double rad2deg(double x); |
| 51 |
InlineDeclare Const double rad2arcmin(double x); |
| 52 |
InlineDeclare Const double rad2arcsec(double x); |
| 53 |
|
| 54 |
InlineDeclare Const double deg2rad(double x); |
| 55 |
InlineDeclare Const double deg2arcmin(double x); |
| 56 |
InlineDeclare Const double deg2arcsec(double x); |
| 57 |
|
| 58 |
InlineDeclare Const double arcmin2rad(double x); |
| 59 |
InlineDeclare Const double arcmin2deg(double x); |
| 60 |
InlineDeclare Const double arcmin2arcsec(double x); |
| 61 |
|
| 62 |
InlineDeclare Const double arcsec2rad(double x); |
| 63 |
InlineDeclare Const double arcsec2deg(double x); |
| 64 |
InlineDeclare Const double arcsec2arcmin(double x); |
| 65 |
|
| 66 |
#define MJD_JD_OFFSET 2400000.5 |
| 67 |
|
| 68 |
InlineDeclare Const double mjdtojd(double mjd); |
| 69 |
InlineDeclare Const double jdtomjd(double jd); |
| 70 |
|
| 71 |
// RA,Dec in radians: |
| 72 |
#define radec2x(r,d) (cos(d)*cos(r)) |
| 73 |
#define radec2y(r,d) (cos(d)*sin(r)) |
| 74 |
#define radec2z(r,d) (sin(d)) |
| 75 |
InlineDeclare Const double xy2ra(double x, double y); |
| 76 |
InlineDeclare Const double z2dec(double z); |
| 77 |
|
| 78 |
double atora(const char* str); |
| 79 |
double atodec(const char* str); |
| 80 |
|
| 81 |
double mag2flux(double mag); |
| 82 |
|
| 83 |
// RA,Dec in radians: |
| 84 |
InlineDeclare void radec2xyz(double ra, double dec, double* x, double* y, double* z); |
| 85 |
InlineDeclare Flatten void xyz2radec(double x, double y, double z, double *ra, double *dec); |
| 86 |
InlineDeclare Flatten void xyzarr2radec(const double* xyz, double *ra, double *dec); |
| 87 |
InlineDeclare void xyzarr2radecarr(const double* xyz, double *radec); |
| 88 |
InlineDeclare void radec2xyzarr(double ra, double dec, double* p_xyz); |
| 89 |
InlineDeclare void radec2xyzarrmany(double *ra, double *dec, double* xyz, int n); |
| 90 |
|
| 91 |
// RA,Dec in degrees: |
| 92 |
InlineDeclare void radecdeg2xyz(double ra, double dec, double* x, double* y, double* z); |
| 93 |
InlineDeclare Flatten void xyzarr2radecdeg(const double* xyz, double *ra, double *dec); |
| 94 |
InlineDeclare Flatten void xyzarr2radecdegarr(double* xyz, double *radec); |
| 95 |
InlineDeclare void radecdeg2xyzarr(double ra, double dec, double* p_xyz); |
| 96 |
InlineDeclare void radecdegarr2xyzarr(double* radec, double* xyz); |
| 97 |
InlineDeclare void radecdeg2xyzarrmany(double *ra, double *dec, double* xyz, int n); |
| 98 |
|
| 99 |
// Converts a distance-squared between two points on the |
| 100 |
// surface of the unit sphere into the angle between the |
| 101 |
// rays from the center of the sphere to the points, in |
| 102 |
// radians. |
| 103 |
InlineDeclare Flatten Const double distsq2arc(double dist2); |
| 104 |
|
| 105 |
// Distance^2 on the unit sphere to radians. |
| 106 |
// (alias of distsq2arc) |
| 107 |
InlineDeclare Flatten Const double distsq2rad(double dist2); |
| 108 |
|
| 109 |
InlineDeclare Flatten Const double distsq2deg(double dist2); |
| 110 |
|
| 111 |
// Distance on the unit sphere to radians. |
| 112 |
InlineDeclare Flatten Const double dist2rad(double dist); |
| 113 |
|
| 114 |
// Distance^2 on the unit sphere to arcseconds. |
| 115 |
InlineDeclare Flatten Const double distsq2arcsec(double dist2); |
| 116 |
|
| 117 |
// Distance on the unit sphere to arcseconds |
| 118 |
InlineDeclare Flatten Const double dist2arcsec(double dist); |
| 119 |
|
| 120 |
// Radians to distance^2 on the unit sphere. |
| 121 |
// (alias of arc2distsq) |
| 122 |
InlineDeclare Const double rad2distsq(double arcInRadians); |
| 123 |
|
| 124 |
// Radians to distance on the unit sphere. |
| 125 |
InlineDeclare Flatten Const double rad2dist(double arcInRadians); |
| 126 |
|
| 127 |
// Converts an angle (in arcseconds) into the distance-squared |
| 128 |
// between two points on the unit sphere separated by that angle. |
| 129 |
InlineDeclare Flatten Const double arcsec2distsq(double arcInArcSec); |
| 130 |
|
| 131 |
// Arcseconds to distance on the unit sphere. |
| 132 |
InlineDeclare Flatten Const double arcsec2dist(double arcInArcSec); |
| 133 |
|
| 134 |
// Degrees to distance on the unit sphere. |
| 135 |
InlineDeclare Flatten Const double deg2dist(double arcInDegrees); |
| 136 |
|
| 137 |
InlineDeclare Flatten Const double deg2distsq(double d); |
| 138 |
|
| 139 |
InlineDeclare Flatten Const double arcmin2dist(double arcmin); |
| 140 |
|
| 141 |
InlineDeclare Flatten Const double arcmin2distsq(double arcmin); |
| 142 |
|
| 143 |
// Distance on the unit sphere to degrees. |
| 144 |
InlineDeclare Flatten Const double dist2deg(double dist); |
| 145 |
|
| 146 |
#define HELP_ERR -101 |
| 147 |
#define OPT_ERR -201 |
| 148 |
|
| 149 |
InlineDeclare void star_midpoint(double* mid, const double* A, const double* B); |
| 150 |
|
| 151 |
#ifdef INCLUDE_INLINE_SOURCE |
| 152 |
#define InlineDefine InlineDefineH |
| 153 |
#include "starutil.inc" |
| 154 |
#undef InlineDefine |
| 155 |
#endif |
| 156 |
|
| 157 |
#endif |