static PJ_LP e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal/spheroidal, inverse */ PJ_LP lp = {0.0,0.0}; struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque); double yc, y2, y6; int i; /* Adjusting x and y for authalic radius */ xy.x /= Q->rqda; xy.y /= Q->rqda; /* Make sure y is inside valid range */ if (xy.y > MAX_Y) xy.y = MAX_Y; else if (xy.y < -MAX_Y) xy.y = -MAX_Y; yc = xy.y; /* Newton-Raphson */ for (i = MAX_ITER; i ; --i) { double f, fder, tol; y2 = yc * yc; y6 = y2 * y2 * y2; f = yc * (A1 + A2 * y2 + y6 * (A3 + A4 * y2)) - xy.y; fder = A1 + 3 * A2 * y2 + y6 * (7 * A3 + 9 * A4 * y2); tol = f / fder; yc -= tol; if (fabs(tol) < EPS) break; } if( i == 0 ) { pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); return lp; } /* Longitude */ y2 = yc * yc; y6 = y2 * y2 * y2; lp.lam = M * xy.x * (A1 + 3 * A2 * y2 + y6 * (7 * A3 + 9 * A4 * y2)) / cos(yc); /* Latitude (for spheroidal case, this is latitude */ lp.phi = asin(sin(yc) / M); /* Ellipsoidal case, converting auth. latitude */ if (P->es != 0.0) lp.phi = pj_authlat(lp.phi, Q->apa); return lp; }
/** * Return the authalic latitude of latitude alpha (if inverse=0) or * return the approximate latitude of authalic latitude alpha (if inverse=1). * P contains the relavent ellipsoid parameters. **/ double auth_lat(PJ *P, double alpha, int inverse) { if (inverse == 0) { /* Authalic latitude. */ double q = pj_qsfn(sin(alpha), P->e, 1.0 - P->es); double qp = P->qp; double ratio = q/qp; if (fabsl(ratio) > 1) { /* Rounding error. */ ratio = pj_sign(ratio); } return asin(ratio); } else { /* Approximation to inverse authalic latitude. */ return pj_authlat(alpha, P->apa); } }
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ LP lp = {0.0,0.0}; struct pj_opaque *Q = P->opaque; double cCe, sCe, q, rho, ab=0.0; switch (Q->mode) { case EQUIT: case OBLIQ: xy.x /= Q->dd; xy.y *= Q->dd; rho = hypot(xy.x, xy.y); if (rho < EPS10) { lp.lam = 0.; lp.phi = P->phi0; return lp; } sCe = 2. * asin(.5 * rho / Q->rq); cCe = cos(sCe); sCe = sin(sCe); xy.x *= sCe; if (Q->mode == OBLIQ) { ab = cCe * Q->sinb1 + xy.y * sCe * Q->cosb1 / rho; xy.y = rho * Q->cosb1 * cCe - xy.y * Q->sinb1 * sCe; } else { ab = xy.y * sCe / rho; xy.y = rho * cCe; } break; case N_POLE: xy.y = -xy.y; /*-fallthrough*/ case S_POLE: q = (xy.x * xy.x + xy.y * xy.y); if (q == 0.0) { lp.lam = 0.; lp.phi = P->phi0; return (lp); } ab = 1. - q / Q->qp; if (Q->mode == S_POLE) ab = - ab; break; } lp.lam = atan2(xy.x, xy.y); lp.phi = pj_authlat(asin(ab), Q->apa); return lp; }
inline T auth_lat(const Parameters& par, const par_healpix<T>& proj_parm, T const& alpha, int inverse) { if (inverse == 0) { /* Authalic latitude. */ T q = pj_qsfn(sin(alpha), par.e, 1.0 - par.es); T qp = proj_parm.qp; T ratio = q/qp; if (math::abs(ratio) > 1) { /* Rounding error. */ ratio = pj_sign(ratio); } return asin(ratio); } else { /* Approximation to inverse authalic latitude. */ return pj_authlat(alpha, proj_parm.apa); } }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double cCe, sCe, q, rho, ab=0.0; switch (this->m_proj_parm.mode) { case EQUIT: case OBLIQ: if ((rho = boost::math::hypot(xy_x /= this->m_proj_parm.dd, xy_y *= this->m_proj_parm.dd)) < EPS10) { lp_lon = 0.; lp_lat = this->m_par.phi0; return; } cCe = cos(sCe = 2. * asin(.5 * rho / this->m_proj_parm.rq)); xy_x *= (sCe = sin(sCe)); if (this->m_proj_parm.mode == OBLIQ) { q = this->m_proj_parm.qp * (ab = cCe * this->m_proj_parm.sinb1 + xy_y * sCe * this->m_proj_parm.cosb1 / rho); xy_y = rho * this->m_proj_parm.cosb1 * cCe - xy_y * this->m_proj_parm.sinb1 * sCe; } else { q = this->m_proj_parm.qp * (ab = xy_y * sCe / rho); xy_y = rho * cCe; } break; case N_POLE: xy_y = -xy_y; case S_POLE: if (!(q = (xy_x * xy_x + xy_y * xy_y)) ) { lp_lon = 0.; lp_lat = this->m_par.phi0; return; } /* q = this->m_proj_parm.qp - q; */ ab = 1. - q / this->m_proj_parm.qp; if (this->m_proj_parm.mode == S_POLE) ab = - ab; break; } lp_lon = atan2(xy_x, xy_y); lp_lat = pj_authlat(asin(ab), this->m_proj_parm.apa); }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { lp_lat = pj_authlat(asin( 2. * xy_y * this->m_par.k0 / this->m_proj_parm.qp), this->m_proj_parm.apa); lp_lon = xy_x / this->m_par.k0; }