protected void ProjectInverseSpherical(double xyx, double xyy, Coordinate dst) { double cosz = 0.0, rh, sinz = 0.0; double lpphi, lplam; rh = ProjectionMath.Hypot(xyx, xyy); if ((lpphi = rh * .5) > 1.0) { throw new ProjectionException("I_ERROR"); } lpphi = 2.0 * Math.Asin(lpphi); if (mode == AzimuthalMode.Oblique || mode == AzimuthalMode.Equator) { sinz = Math.Sin(lpphi); cosz = Math.Cos(lpphi); } switch (mode) { case AzimuthalMode.Equator: lpphi = Math.Abs(rh) <= EPS10 ? 0.0 : Math.Asin(xyy * sinz / rh); xyx *= sinz; xyy = cosz * rh; break; case AzimuthalMode.Oblique: lpphi = Math.Abs(rh) <= EPS10 ? phi0 : Math.Asin(cosz * sinph0 + xyy * sinz * cosph0 / rh); xyx *= sinz * cosph0; xyy = (cosz - Math.Sin(lpphi) * sinph0) * rh; break; case AzimuthalMode.NorthPole: xyy = -xyy; lpphi = ProjectionMath.PiHalf - lpphi; break; case AzimuthalMode.SouthPole: lpphi -= ProjectionMath.PiHalf; break; } lplam = (xyy == 0.0 && (mode == AzimuthalMode.Equator || mode == AzimuthalMode.Oblique)) ? 0.0 : Math.Atan2(xyx, xyy); dst.X = lplam; dst.Y = lpphi; }
protected void ProjectInverseNonSpherical(double xyx, double xyy, Coordinate dst) { double lpphi, lplam; double cCe, sCe, q, rho, ab = 0.0; switch (mode) { case AzimuthalMode.Equator: case AzimuthalMode.Oblique: if ((rho = ProjectionMath.Hypot(xyx /= dd, xyy *= dd)) < EPS10) { lplam = 0.0; lpphi = phi0; dst.X = lplam; dst.Y = lpphi; return; } cCe = Math.Cos(sCe = 2.0 * Math.Asin(.5 * rho / rq)); xyx *= (sCe = Math.Sin(sCe)); if (mode == AzimuthalMode.Oblique) { q = qp * (ab = cCe * sinb1 + xyy * sCe * cosb1 / rho); xyy = rho * cosb1 * cCe - xyy * sinb1 * sCe; } else { q = qp * (ab = xyy * sCe / rho); xyy = rho * cCe; } break; case AzimuthalMode.NorthPole: case AzimuthalMode.SouthPole: if (mode == AzimuthalMode.NorthPole) { xyy = -xyy; } if (0 == (q = (xyx * xyx + xyy * xyy))) { lplam = 0.0; lpphi = phi0; dst.X = lplam; dst.Y = lpphi; return; } /* * q = P->qp - q; */ ab = 1.0 - q / qp; if (mode == AzimuthalMode.SouthPole) { ab = -ab; } break; } lplam = Math.Atan2(xyx, xyy); lpphi = ProjectionMath.AuthLat(Math.Asin(ab), apa); dst.X = lplam; dst.Y = lpphi; }