/// <inheritdoc /> protected override void EllipticalInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double s; double rh = Proj.Hypot(xy[x], xy[y] = _am1 - xy[y]); lp[phi] = Proj.InvMlfn(_am1 + _m1 - rh, Es, _en); if ((s = Math.Abs(lp[phi])) < HALF_PI) { s = Math.Sin(lp[phi]); lp[lam] = rh * Math.Atan2(xy[x], xy[y]) * Math.Sqrt(1 - Es * s * s) / Math.Cos(lp[phi]); } else if (Math.Abs(s - HALF_PI) <= EPS10) { lp[lam] = 0; } else { lp[lam] = double.NaN; lp[phi] = double.NaN; continue; //throw new ProjectionException(20); } } }
/// <inheritdoc /> protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; if ((_rho = Proj.Hypot(xy[x], xy[y] = _rho0 - xy[y])) != 0.0) { if (_n < 0) { _rho = -_rho; xy[x] = -xy[x]; xy[y] = -xy[y]; } lp[phi] = _c - _rho; if (IsElliptical) { lp[phi] = Proj.InvMlfn(lp[phi], Es, _en); } lp[lam] = Math.Atan2(xy[x], xy[y]) / _n; } else { lp[lam] = 0; lp[phi] = _n > 0 ? HALF_PI : -HALF_PI; } } }
/// <inheritdoc /> protected override void SphericalInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double rh = Proj.Hypot(xy[x], xy[y] = _cphi1 - xy[y]); lp[phi] = _cphi1 + _phi1 - rh; if (Math.Abs(lp[phi]) > HALF_PI) { lp[lam] = double.NaN; lp[phi] = double.NaN; continue; //throw new ProjectionException(20); } if (Math.Abs(Math.Abs(lp[phi]) - HALF_PI) <= EPS10) { lp[lam] = 0; } else { lp[lam] = rh * Math.Atan2(xy[x], xy[y]) / Math.Cos(lp[phi]); } } }
/// <inheritdoc /> protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double cz1 = Math.Cos(Proj.Hypot(xy[y], xy[x] + _hz0)); double cz2 = Math.Cos(Proj.Hypot(xy[y], xy[x] - _hz0)); double s = cz1 + cz2; double d = cz1 - cz2; lp[lam] = -Math.Atan2(d, (s * _thz0)); lp[phi] = Proj.Aacos(Proj.Hypot(_thz0 * s, d) * _rhshz0); if (xy[y] < 0) { lp[phi] = -lp[phi]; } /* lam--phi now in system relative to P1--P2 base equator */ double sp = Math.Sin(lp[phi]); double cp = Math.Cos(lp[phi]); lp[phi] = Proj.Aasin(_sa * sp + _ca * cp * (s = Math.Cos(lp[lam] -= _lp))); lp[lam] = Math.Atan2(cp * Math.Sin(lp[lam]), _sa * cp * s - _ca * sp) + _lamc; } }
/// <inheritdoc /> protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double rho; xy[x] /= K0; xy[y] /= K0; if ((rho = Proj.Hypot(xy[x], xy[y])) > 0) { double c = 2 * Math.Atan2(rho, _r2); double sinc = Math.Sin(c); double cosc = Math.Cos(c); lp[phi] = Math.Asin(cosc * _sinc0 + xy[y] * sinc * _cosc0 / rho); lp[lam] = Math.Atan2(xy[x] * sinc, rho * _cosc0 * cosc - xy[y] * _sinc0 * sinc); } else { lp[phi] = _phic0; lp[lam] = 0; } } _gauss.Inverse(lp, startIndex, numPoints); }
/// <inheritdoc /> protected override void EllipticalForward(double[] lp, double[] xy, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; /* Calculation of geocentric latitude. */ lp[phi] = Math.Atan(_radiusP2 * Math.Tan(lp[phi])); /* Calculation of the three components of the vector from satellite to ** position on earth surface (lon, lat).*/ double r = (_radiusP) / Proj.Hypot(_radiusP * Math.Cos(lp[phi]), Math.Sin(lp[phi])); double vx = r * Math.Cos(lp[lam]) * Math.Cos(lp[phi]); double vy = r * Math.Sin(lp[lam]) * Math.Cos(lp[phi]); double vz = r * Math.Sin(lp[phi]); /* Check visibility. */ if (((_radiusG - vx) * vx - vy * vy - vz * vz * _radiusPInv2) < 0) { xy[x] = double.NaN; xy[y] = double.NaN; continue; // throw new ProjectionException(20); } /* Calculation based on view angles from satellite. */ double tmp = _radiusG - vx; xy[x] = _radiusG1 * Math.Atan(vy / tmp); xy[y] = _radiusG1 * Math.Atan(vz / Proj.Hypot(vy, tmp)); } }
/// <inheritdoc /> protected override void EllipticalInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double ab; double cx = xy[x]; double cy = xy[y]; if (_mode == Modes.Equitorial || _mode == Modes.Oblique) { double rho = Proj.Hypot(cx /= _dd, cy * _dd); if (rho < EPS10) { lp[lam] = 0; lp[phi] = Phi0; return; } double sCe; double cCe = Math.Cos(sCe = 2 * Math.Asin(.5 * rho / _rq)); cx *= (sCe = Math.Sin(sCe)); if (_mode == Modes.Oblique) { ab = cCe * _sinb1 + y * sCe * _cosb1 / rho; //q = _qp*(ab); cy = rho * _cosb1 * cCe - cy * _sinb1 * sCe; } else { ab = cy * sCe / rho; //q = _qp*(ab); cy = rho * cCe; } } else { if (_mode == Modes.NorthPole) { cy = -cy; } double q; if ((q = (cx * cx + cy * cy)) == 0) { lp[lam] = 0; lp[phi] = Phi0; return; } ab = 1 - q / _qp; if (_mode == Modes.SouthPole) { ab = -ab; } } lp[lam] = Math.Atan2(cx, cy); lp[phi] = Proj.AuthLat(Math.Asin(ab), _apa); } }
/// <inheritdoc /> protected override void SphericalInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double cRh; if ((cRh = Proj.Hypot(xy[x], xy[y])) > Math.PI) { if (cRh - EPS10 > Math.PI) { lp[phi] = double.NaN; lp[lam] = double.NaN; continue; //throw new ProjectionException(20); } cRh = Math.PI; } else if (cRh < EPS10) { lp[phi] = Phi0; lp[lam] = 0; return; } if (_mode == Modes.Oblique || _mode == Modes.Equitorial) { double sinc = Math.Sin(cRh); double cosc = Math.Cos(cRh); if (_mode == Modes.Equitorial) { lp[phi] = Proj.Aasin(xy[y] * sinc / cRh); xy[x] *= sinc; xy[y] = cosc * cRh; } else { lp[phi] = Proj.Aasin(cosc * _sinph0 + xy[y] * sinc * _cosph0 / cRh); xy[y] = (cosc - _sinph0 * Math.Sin(lp[phi])) * cRh; xy[x] *= sinc * _cosph0; } lp[lam] = xy[y] == 0 ? 0 : Math.Atan2(xy[x], xy[y]); } else if (_mode == Modes.NorthPole) { lp[phi] = HALF_PI - cRh; lp[lam] = Math.Atan2(xy[x], -xy[y]); } else { lp[phi] = cRh - HALF_PI; lp[lam] = Math.Atan2(xy[x], xy[y]); } } }
/// <inheritdoc /> protected override void EllipticalInverse(double[] xy, double[] lp, int startIndex, int numPoints) { if (_isGuam) { GuamInverse(xy, lp, startIndex, numPoints); } for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double c; if ((c = Proj.Hypot(xy[x], xy[y])) < EPS10) { lp[phi] = Phi0; lp[lam] = 0; continue; } if (_mode == Modes.Oblique || _mode == Modes.Equitorial) { double az; double cosAz = Math.Cos(az = Math.Atan2(xy[x], xy[y])); double t = _cosph0 * cosAz; double b = Es * t / OneEs; double a = -b * t; b *= 3 * (1 - a) * _sinph0; double d = c / _n1; double e = d * (1 - d * d * (a * (1 + a) / 6 + b * (1 + 3 * a) * d / 24)); double f = 1 - e * e * (a / 2 + b * e / 6); double psi = Proj.Aasin(_sinph0 * Math.Cos(e) + t * Math.Sin(e)); lp[lam] = Proj.Aasin(Math.Sin(az) * Math.Sin(e) / Math.Cos(psi)); if ((t = Math.Abs(psi)) < EPS10) { lp[phi] = 0; } else if (Math.Abs(t - HALF_PI) < 0) { lp[phi] = HALF_PI; } else { lp[phi] = Math.Atan((1 - Es * f * _sinph0 / Math.Sin(psi)) * Math.Tan(psi) / OneEs); } } else { /* Polar */ lp[phi] = Proj.InvMlfn(_mode == Modes.NorthPole ? _mp - c : _mp + c, Es, _en); lp[lam] = Math.Atan2(xy[x], _mode == Modes.NorthPole ? -xy[y] : xy[y]); } } }
/// <inheritdoc /> protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; if ((_rho = Proj.Hypot(xy[x], xy[y] = _rho0 - xy[y])) != 0.0) { if (_n < 0) { _rho = -_rho; xy[x] = -xy[x]; xy[y] = -xy[y]; } lp[phi] = _rho / _dd; if (IsElliptical) { lp[phi] = (_c - lp[phi] * lp[phi]) / _n; if (Math.Abs(_ec - Math.Abs(lp[phi])) > TOL7) { if ((lp[phi] = PhiFn(lp[phi], E, OneEs)) == double.MaxValue) { lp[phi] = double.NaN; lp[lam] = double.NaN; continue; //throw new ProjectionException(20); } } else { lp[phi] = lp[phi] < 0 ? -HALF_PI : HALF_PI; } } else if (Math.Abs(lp[phi] = (_c - lp[phi] * lp[phi]) / _n2) <= 1) { lp[phi] = Math.Asin(lp[phi]); } else { lp[phi] = lp[phi] < 0 ? -HALF_PI : HALF_PI; } lp[lam] = Math.Atan2(xy[x], xy[y]) / _n; } else { lp[lam] = 0; lp[phi] = _n > 0 ? HALF_PI : -HALF_PI; } } }
/// <inheritdoc /> protected override void SphericalInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double cosz = 0, sinz = 0; double cx = xy[x]; double cy = xy[y]; double rh = Proj.Hypot(x, y); if ((lp[phi] = rh * .5) > 1) { lp[lam] = double.NaN; lp[phi] = double.NaN; continue; //throw new ProjectionException(20); } lp[phi] = 2 * Math.Asin(lp[phi]); if (_mode == Modes.Oblique || _mode == Modes.Equitorial) { sinz = Math.Sin(lp[phi]); cosz = Math.Cos(lp[phi]); } switch (_mode) { case Modes.Equitorial: lp[phi] = Math.Abs(rh) <= EPS10 ? 0 : Math.Asin(cy * sinz / rh); cx *= sinz; cy = cosz * rh; break; case Modes.Oblique: lp[phi] = Math.Abs(rh) <= EPS10 ? Phi0 : Math.Asin(cosz * _sinb1 + y * sinz * _sinb1 / rh); cx *= sinz * _cosb1; cy = (cosz - Math.Sin(lp[phi]) * _sinb1) * rh; break; case Modes.NorthPole: cy = -cy; lp[phi] = HALF_PI - lp[phi]; break; case Modes.SouthPole: lp[phi] -= HALF_PI; break; } lp[lam] = (y == 0 && (_mode == Modes.Equitorial || _mode == Modes.Oblique)) ? 0 : Math.Atan2(cx, cy); } }
/// <inheritdoc /> protected override void EllipticalInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double det; /* Setting three components of vector from satellite to position.*/ double vx = -1.0; double vy = Math.Tan(xy[x] / _radiusG1); double vz = Math.Tan(xy[y] / _radiusG1) * Proj.Hypot(1.0, vy); /* Calculation of terms in cubic equation and determinant.*/ double a = vz / _radiusP; a = vy * vy + a * a + vx * vx; double b = 2 * _radiusG * vx; if ((det = (b * b) - 4 * a * _c) < 0) { lp[lam] = double.NaN; lp[phi] = double.NaN; continue; //throw new ProjectionException(20); } /* Calculation of three components of vector from satellite to position.*/ double k = (-b - Math.Sqrt(det)) / (2 * a); vx = _radiusG + k * vx; vy *= k; vz *= k; /* Calculation of longitude and latitude.*/ lp[lam] = Math.Atan2(vy, vx); lp[phi] = Math.Atan(vz * Math.Cos(lp[lam]) / vx); lp[phi] = Math.Atan(_radiusPInv2 * Math.Tan(lp[phi])); } }
/// <inheritdoc /> protected override void SphericalInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double c, rh; double sinc = Math.Sin(c = 2 * Math.Atan((rh = Proj.Hypot(xy[x], xy[y])) / _akm1)); double cosc = Math.Cos(c); lp[lam] = 0; switch (_mode) { case Modes.Equitorial: if (Math.Abs(rh) <= EPS10) { lp[phi] = 0; } else { lp[phi] = Math.Asin(xy[y] * sinc / rh); } if (cosc != 0 || xy[x] != 0) { lp[lam] = Math.Atan2(xy[x] * sinc, cosc * rh); } break; case Modes.Oblique: if (Math.Abs(rh) <= EPS10) { lp[phi] = Phi0; } else { lp[phi] = Math.Asin(cosc * _sinX1 + xy[y] * sinc * _cosX1 / rh); } if ((c = cosc - _sinX1 * Math.Sin(lp[phi])) != 0 || xy[x] != 0) { lp[lam] = Math.Atan2(xy[x] * sinc * _cosX1, c * rh); } break; case Modes.NorthPole: case Modes.SouthPole: if (_mode == Modes.NorthPole) { xy[y] = -xy[y]; } if (Math.Abs(rh) <= EPS10) { lp[phi] = Phi0; } else { lp[phi] = Math.Asin(_mode == Modes.SouthPole ? -cosc : cosc); } lp[lam] = (xy[x] == 0 && xy[y] == 0) ? 0 : Math.Atan2(xy[x], xy[y]); break; } } }
/// <inheritdoc /> protected override void EllipticalInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double sinphi, tp = 0.0, phiL = 0.0, halfe = 0.0, halfpi = 0.0; int j; double rho = Proj.Hypot(xy[x], xy[y]); switch (_mode) { case Modes.Oblique: case Modes.Equitorial: double cosphi = Math.Cos(tp = 2 * Math.Atan2(rho * _cosX1, _akm1)); sinphi = Math.Sin(tp); if (rho == 0.0) { phiL = Math.Asin(cosphi * _sinX1); } else { phiL = Math.Asin(cosphi * _sinX1 + (xy[y] * sinphi * _cosX1 / rho)); } tp = Math.Tan(.5 * (HALF_PI + phiL)); xy[x] *= sinphi; xy[y] = rho * _cosX1 * cosphi - xy[y] * _sinX1 * sinphi; halfpi = HALF_PI; halfe = .5 * E; break; case Modes.NorthPole: case Modes.SouthPole: if (_mode == Modes.NorthPole) { xy[y] = -xy[y]; } phiL = HALF_PI - 2 * Math.Atan(tp = -rho / _akm1); halfpi = -HALF_PI; halfe = -.5 * E; break; } for (j = NITER; j-- > 0; phiL = lp[phi]) { sinphi = E * Math.Sin(phiL); lp[phi] = 2 * Math.Atan(tp * Math.Pow((1 + sinphi) / (1 - sinphi), halfe)) - halfpi; if (Math.Abs(phiL - lp[phi]) < CONV) { if (_mode == Modes.SouthPole) { lp[phi] = -lp[phi]; } lp[lam] = (xy[x] == 0 && xy[y] == 0) ? 0 : Math.Atan2(xy[x], xy[y]); return; } } lp[lam] = double.NaN; lp[phi] = double.NaN; continue; //ProjectionException(20); } }
/// <inheritdoc /> protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double rh = Proj.Hypot(xy[x], xy[y]); double sinz = Math.Sin(lp[phi] = Math.Atan(rh)); double cosz = Math.Sqrt(1 - sinz * sinz); if (Math.Abs(rh) <= EPS10) { lp[phi] = Phi0; lp[lam] = 0; } else { switch (_mode) { case Modes.Oblique: lp[phi] = cosz * _sinph0 + xy[y] * sinz * _cosph0 / rh; if (Math.Abs(lp[phi]) >= 1) { lp[phi] = lp[phi] > 0 ? HALF_PI : -HALF_PI; } else { lp[phi] = Math.Asin(lp[phi]); } xy[y] = (cosz - _sinph0 * Math.Sin(lp[phi])) * rh; xy[x] *= sinz * _cosph0; break; case Modes.Equitorial: lp[phi] = xy[y] * sinz / rh; if (Math.Abs(lp[phi]) >= 1) { lp[phi] = lp[phi] > 0 ? HALF_PI : -HALF_PI; } else { lp[phi] = Math.Asin(lp[phi]); } xy[y] = cosz * rh; xy[x] *= sinz; break; case Modes.SouthPole: lp[phi] -= HALF_PI; break; case Modes.NorthPole: lp[phi] = HALF_PI - lp[phi]; xy[y] = -xy[y]; break; } lp[lam] = Math.Atan2(xy[x], xy[y]); } } }
/// <inheritdoc /> protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double rh, sinc; double cx = xy[x]; double cy = xy[y]; if ((sinc = (rh = Proj.Hypot(cx, cy))) > 1) { if ((sinc - 1) > EPS10) { lp[lam] = double.NaN; lp[phi] = double.NaN; continue; //ProjectionException(20); } sinc = 1; } double cosc = Math.Sqrt(1 - sinc * sinc); if (Math.Abs(rh) <= EPS10) { lp[phi] = Phi0; lp[lam] = 0; } else { switch (_mode) { case Modes.NorthPole: cy = -cy; lp[phi] = Math.Acos(sinc); break; case Modes.SouthPole: lp[phi] = -Math.Acos(sinc); break; case Modes.Equitorial: lp[phi] = cy * sinc / rh; cx *= sinc; cy = cosc * rh; if (Math.Abs(lp[phi]) >= 1) { lp[phi] = lp[phi] < 0 ? -HALF_PI : HALF_PI; } else { lp[phi] = Math.Asin(lp[phi]); } break; case Modes.Oblique: lp[phi] = cosc * _sinph0 + cy * sinc * _cosph0 / rh; cy = (cosc - _sinph0 * lp[phi]) * rh; cx *= sinc * _cosph0; if (Math.Abs(lp[phi]) >= 1) { lp[phi] = lp[phi] < 0 ? -HALF_PI : HALF_PI; } else { lp[phi] = Math.Asin(lp[phi]); } break; } lp[lam] = (cy == 0 && (_mode == Modes.Oblique || _mode == Modes.Equitorial)) ? (cx == 0 ? 0 : cx < 0 ? -HALF_PI : HALF_PI) : Math.Atan2(cx, cy); } } }
/// <inheritdoc /> protected override void OnInverse(double[] xy, double[] lp, int startIndex, int numPoints) { for (int i = startIndex; i < startIndex + numPoints; i++) { int phi = i * 2 + PHI; int lam = i * 2 + LAMBDA; int x = i * 2 + X; int y = i * 2 + Y; double r, rp; double z = 0, az, s, c, av; int j; if (_noskew) { double t = xy[x]; xy[x] = -xy[x] * C_AZC + xy[y] * S_AZC; xy[y] = -xy[y] * C_AZC - t * S_AZC; } bool neg = (xy[x] < 0); if (neg) { xy[y] = RHOC - xy[y]; s = S20; c = C20; av = AZAB; } else { xy[y] += RHOC; s = S45; c = C45; av = AZBA; } double rl = rp = r = Proj.Hypot(xy[x], xy[y]); double fAz = Math.Abs(az = Math.Atan2(xy[x], xy[y])); for (j = NITER; j > 0; --j) { z = 2 * Math.Atan(Math.Pow(r / F, 1 / N)); double al = Math.Acos((Math.Pow(Math.Tan(.5 * z), N) + Math.Pow(Math.Tan(.5 * (R104 - z)), N)) / T); if (fAz < al) { r = rp * Math.Cos(al + (neg ? az : -az)); } if (Math.Abs(rl - r) < EPS) { break; } rl = r; } if (j == 0) { lp[phi] = double.NaN; lp[lam] = double.NaN; continue; //throw new ProjectionException(20); } az = av - az / N; lp[phi] = Math.Asin(s * Math.Cos(z) + c * Math.Sin(z) * Math.Cos(az)); lp[lam] = Math.Atan2(Math.Sin(az), c / Math.Tan(z) - s * Math.Cos(az)); if (neg) { lp[lam] -= R110; } else { lp[lam] = LAM_B - lp[lam]; } } }