38 vec3 Trafo::xcc_dp_precess (
const vec3 &iv,
double iepoch,
42 double Tm = ((oepoch+iepoch)*0.5 - 1900.) *0.01;
43 double gp_long = degr2rad * ((oepoch-iepoch) * (50.2564+0.0222*Tm) / 3600.);
45 degr2rad * (180. - (173. + (57.06+54.77*Tm) / 60.)) + gp_long*0.5;
46 double dco = cos(obl_long), dso = sin(obl_long);
47 vec3 ov (iv.x*dco-iv.y*dso, iv.x*dso+iv.y*dco, iv.z);
50 double dE = degr2rad * ((oepoch-iepoch) * (0.4711-0.0007*Tm) / 3600.);
51 double dce = cos(dE), dse = sin(dE);
52 double temp = ov.y*dce - ov.z*dse;
53 ov.z = ov.y*dse + ov.z*dce;
57 double dL = gp_long - obl_long;
58 double dcl = cos(dL), dsl = sin(dL);
59 temp = ov.x*dcl - ov.y*dsl;
60 ov.y = ov.x*dsl + ov.y*dcl;
66 double Trafo::get_epsilon (
double epoch)
68 double T = (epoch - 1900.) * 0.01;
70 degr2rad * (23.452294 - 0.0130125*T - 1.63889e-6*T*T + 5.02778e-7*T*T*T);
76 vec3 Trafo::xcc_dp_e_to_q (
const vec3 &iv,
double epoch)
78 double epsilon=get_epsilon(epoch);
79 double dc = cos(epsilon), ds = sin(epsilon);
80 return vec3 (iv.
x, dc*iv.
y-ds*iv.
z, dc*iv.
z+ds*iv.
y);
83 vec3 Trafo::xcc_dp_q_to_e (
const vec3 &iv,
double epoch)
85 double epsilon=-get_epsilon(epoch);
86 double dc = cos(epsilon), ds = sin(epsilon);
87 return vec3 (iv.
x, dc*iv.
y-ds*iv.
z, dc*iv.
z+ds*iv.
y);
93 vec3 Trafo::xcc_dp_g_to_e (
const vec3 &iv,
double epoch)
95 static const rotmatrix T (-0.054882486, 0.494116468, -0.867661702,
96 -0.993821033, -0.110993846, -0.000346354,
97 -0.096476249, 0.862281440, 0.497154957);
98 vec3 hv=T.Transform(iv);
101 hv=xcc_dp_precess(hv,2000.,epoch);
109 vec3 Trafo::xcc_dp_e_to_g (
const vec3 &iv,
double epoch)
111 static const rotmatrix T (-0.054882486, -0.993821033, -0.096476249,
112 0.494116468, -0.110993846, 0.862281440,
113 -0.867661702, -0.000346354, 0.497154957);
116 hv=xcc_dp_precess(hv,epoch,2000.);
118 return T.Transform(hv);
123 vec3 Trafo::xcc_v_convert(
const vec3 &iv,
double iepoch,
double oepoch,
124 coordsys isys,coordsys osys)
127 if (isys == Ecliptic)
129 else if (isys == Equatorial)
130 xv = xcc_dp_q_to_e(iv,iepoch);
131 else if (isys == Galactic)
132 xv = xcc_dp_g_to_e(iv,iepoch);
134 planck_fail(
"Unsupported input coordinate system");
136 vec3 yv =
approx(iepoch,oepoch) ? xv : xcc_dp_precess(xv,iepoch,oepoch);
139 if (osys == Ecliptic)
141 else if (osys == Equatorial)
142 ov = xcc_dp_e_to_q(yv,oepoch);
143 else if (osys == Galactic)
144 ov = xcc_dp_e_to_g(yv,oepoch);
146 planck_fail(
"Unsupported output coordinate system");
151 void Trafo::coordsys2matrix (
double iepoch,
double oepoch,
152 coordsys isys, coordsys osys,
rotmatrix &matrix)
154 vec3 v1p = xcc_v_convert(
vec3(1,0,0),iepoch,oepoch,isys,osys),
155 v2p = xcc_v_convert(
vec3(0,1,0),iepoch,oepoch,isys,osys),
156 v3p = xcc_v_convert(
vec3(0,0,1),iepoch,oepoch,isys,osys);
157 v1p.
Normalize(); v2p.Normalize(); v3p.Normalize();
161 Trafo::Trafo (
double iepoch,
double oepoch, coordsys isys, coordsys osys)
162 { coordsys2matrix (iepoch, oepoch, isys, osys, mat); }
168 double &delta_psi)
const 171 vec3 east (-vec.
y,vec.
x,0.);
172 vec3 newvec = operator()(vec);
173 vec3 neweast = operator()(east);
181 vec3 east (-vec.
y,vec.
x,0.);
182 vec3 newvec = operator()(vec);
183 vec3 neweast = operator()(east);
190 vec3 east (-vec.
y,vec.
x,0.);
191 newvec = operator()(vec);
192 vec3 neweast = operator()(east);
198 vec3 east (-vec.
y,vec.
x,0.);
199 vec3 newvec = operator()(vec);
200 vec3 neweast = operator()(east);
Trafo(double iepoch, double oepoch, coordsys isys, coordsys osys)
vec3 operator()(const vec3 &vec) const
double orientation(const vec3 &loc, const vec3 &dir)
bool approx(F a, F b, F epsilon=1e-5)
void rotatefull(const pointing &ptg, pointing &newptg, double &delta_psi) const