96 vector<double> observerLookVectorToTarget) {
108 SpiceDouble plat, plon, pradius;
120 SpiceDouble ulookB[3];
121 ulookB[0] = observerLookVectorToTarget[0];
122 ulookB[1] = observerLookVectorToTarget[1];
123 ulookB[2] = observerLookVectorToTarget[2];
124 vhat_c(ulookB, ulookB);
128 SpiceDouble observer[3];
129 observer[0] = observerBodyFixedPos[0];
130 observer[1] = observerBodyFixedPos[1];
131 observer[2] = observerBodyFixedPos[2];
133 SpiceDouble negobserver[3];
134 vminus_c(observer, negobserver);
136 double psi0 = vsep_c(negobserver, ulookB);
141 if (psi0 >
PI / 2.0) {
156 vperp_c(&observer, &ulookB, perp);
158 vsub_c(&observer, &perp, v);
159 double dot = vdot_c(ulookB, v);
160 qDebug() <<
"dot = " << dot;
179 double observerdist = vnorm_c(observer);
180 double cospsi0 = cos(psi0);
181 tvec[0] = observer[0] + observerdist * cospsi0 * ulookB[0];
182 tvec[1] = observer[1] + observerdist * cospsi0 * ulookB[1];
183 tvec[2] = observer[2] + observerdist * cospsi0 * ulookB[2];
185 double tlen = vnorm_c(tvec);
188 double radiusDiff = maxRadiusMetersSquared - tlen * tlen;
191 if (radiusDiff >= 0.0) {
192 radiusDiff = sqrt(radiusDiff);
199 double d0 = observerdist * cospsi0 - radiusDiff;
200 double dm = observerdist * cospsi0 + radiusDiff;
205 g1[0] = observer[0] + d0 * ulookB[0];
206 g1[1] = observer[1] + d0 * ulookB[1];
207 g1[2] = observer[2] + d0 * ulookB[2];
209 double g1len = vnorm_c(g1);
210 SpiceDouble g1lat, g1lon, g1radius;
211 reclat_c(g1, &g1radius, &g1lon, &g1lat);
215 if (g1lon < 0.0) g1lon += 360.0;
217 SpiceDouble negg1[3];
220 double psi1 = vsep_c(negg1, ulookB);
238 double tolerance = 3
E-8 * a;
253 double psi2 = psi1 + dalpha;
256 double dd = g1len * sin(dalpha) / sin(
PI - psi2);
263 if (dd < tolerance) {
272 g2[0] = observer[0] + d * ulookB[0];
273 g2[1] = observer[1] + d * ulookB[1];
274 g2[2] = observer[2] + d * ulookB[2];
276 double g2len = vnorm_c(g2);
279 SpiceDouble g2lat, g2lon, g2radius;
280 reclat_c(g2, &g2radius, &g2lon, &g2lat);
285 if (g2lon < 0.0) g2lon += 360.0;
305 while (it < maxit && !done) {
310 if ((g2len * r1 / r2 - g1len) == 0.0) {
317 double v = (r1 - g1len) / (g2len * r1 / r2 - g1len);
318 pB[0] = g1[0] + v * dd * ulookB[0];
319 pB[1] = g1[1] + v * dd * ulookB[1];
320 pB[2] = g1[2] + v * dd * ulookB[2];
322 reclat_c(pB, &pradius, &plon, &plat);
325 if (plon < 0.0) plon += 360.0;
327 if (plon > 360.0) plon -= 360.0;
337 palt = plen - pradius;
341 if (palt > tolerance) {
353 else if (palt < -tolerance) {
371 if (!done && it >= maxit) {
396 SpiceDouble intersectionPoint[3];
400 surfpt_c(&observerBodyFixedPos[0], &observerLookVectorToTarget[0], plen, plen, plen,
401 intersectionPoint, &found);