static void Main(string[] args) { try { EllipticFunction ell = new EllipticFunction(0.1, 1.0); // parameter m = 0.1 // See Abramowitz and Stegun, table 17.1 Console.WriteLine( String.Format( "{0} {1}", ell.K(), ell.E())); double phi = 20 * Math.Acos(-1.0) / 180.0;; // See Abramowitz and Stegun, table 17.6 with // alpha = asin(sqrt(m)) = 18.43 deg and phi = 20 deg Console.WriteLine( String.Format("{0} {1}", ell.E(phi), ell.E(Math.Sin(phi), Math.Cos(phi), Math.Sqrt(1 - ell.k2 * Math.Sin(phi) * Math.Sin(phi))) ) ); // See Carlson 1995, Sec 3. Console.WriteLine(String.Format("RF(1,2,0) = {0}", EllipticFunction.RF(1,2))); Console.WriteLine(String.Format("RF(2,3,4) = {0}", EllipticFunction.RF(2,3,4))); Console.WriteLine(String.Format("RC(0,1/4) = {0}", EllipticFunction.RC(0,0.25))); Console.WriteLine(String.Format("RC(9/4,2) = {0}", EllipticFunction.RC(2.25,2))); Console.WriteLine(String.Format("RC(1/4,-2) = {0}", EllipticFunction.RC(0.25,-2))); Console.WriteLine(String.Format("RJ(0,1,2,3) = {0}", EllipticFunction.RJ(0,1,2,3))); Console.WriteLine(String.Format("RJ(2,3,4,5) = {0}", EllipticFunction.RJ(2,3,4,5))); Console.WriteLine(String.Format("RD(0,2,1) = {0}", EllipticFunction.RD(0,2,1))); Console.WriteLine(String.Format("RD(2,3,4) = {0}", EllipticFunction.RD(2,3,4))); Console.WriteLine(String.Format("RG(0,16,16) = {0}", EllipticFunction.RG(16,16))); Console.WriteLine(String.Format("RG(2,3,4) = {0}", EllipticFunction.RG(2,3,4))); Console.WriteLine(String.Format("RG(0,0.0796,4) = {0}", EllipticFunction.RG(0.0796, 4))); } catch (GeographicErr e) { Console.WriteLine( String.Format( "Caught exception: {0}", e.Message ) ); } }
private void OnSet(object sender, EventArgs e) { try { double k2 = Double.Parse(m_k2TextBox.Text); double alpha2 = Double.Parse(m_alpha2TextBox.Text); if (m_constructorComboBox.SelectedIndex == 0) { m_func = new EllipticFunction(k2, alpha2); } else { double kp2 = Double.Parse(m_kp2TextBox.Text); double alphap2 = Double.Parse(m_alphap2TextBox.Text); m_func = new EllipticFunction(k2, alpha2, kp2, alphap2); } m_KtextBox.Text = m_func.K().ToString(); m_EtextBox.Text = m_func.E().ToString(); m_DtextBox.Text = m_func.D().ToString(); m_KEtextBox.Text = m_func.KE().ToString(); m_PItextBox.Text = m_func.Pi().ToString(); m_GtextBox.Text = m_func.G().ToString(); m_HtextBox.Text = m_func.H().ToString(); } catch (Exception xcpt) { MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
static void Main(string[] args) { try { EllipticFunction ell = new EllipticFunction(0.1, 1.0); // parameter m = 0.1 // See Abramowitz and Stegun, table 17.1 Console.WriteLine(String.Format("{0} {1}", ell.K(), ell.E())); double phi = 20 * Math.Acos(-1.0) / 180.0;; // See Abramowitz and Stegun, table 17.6 with // alpha = asin(sqrt(m)) = 18.43 deg and phi = 20 deg Console.WriteLine(String.Format("{0} {1}", ell.E(phi), ell.E(Math.Sin(phi), Math.Cos(phi), Math.Sqrt(1 - ell.k2 * Math.Sin(phi) * Math.Sin(phi))))); // See Carlson 1995, Sec 3. Console.WriteLine(String.Format("RF(1,2,0) = {0}", EllipticFunction.RF(1, 2))); Console.WriteLine(String.Format("RF(2,3,4) = {0}", EllipticFunction.RF(2, 3, 4))); Console.WriteLine(String.Format("RC(0,1/4) = {0}", EllipticFunction.RC(0, 0.25))); Console.WriteLine(String.Format("RC(9/4,2) = {0}", EllipticFunction.RC(2.25, 2))); Console.WriteLine(String.Format("RC(1/4,-2) = {0}", EllipticFunction.RC(0.25, -2))); Console.WriteLine(String.Format("RJ(0,1,2,3) = {0}", EllipticFunction.RJ(0, 1, 2, 3))); Console.WriteLine(String.Format("RJ(2,3,4,5) = {0}", EllipticFunction.RJ(2, 3, 4, 5))); Console.WriteLine(String.Format("RD(0,2,1) = {0}", EllipticFunction.RD(0, 2, 1))); Console.WriteLine(String.Format("RD(2,3,4) = {0}", EllipticFunction.RD(2, 3, 4))); Console.WriteLine(String.Format("RG(0,16,16) = {0}", EllipticFunction.RG(16, 16))); Console.WriteLine(String.Format("RG(2,3,4) = {0}", EllipticFunction.RG(2, 3, 4))); Console.WriteLine(String.Format("RG(0,0.0796,4) = {0}", EllipticFunction.RG(0.0796, 4))); } catch (GeographicErr e) { Console.WriteLine(String.Format("Caught exception: {0}", e.Message)); } }
private void OnValidate(object sender, EventArgs e) { try { double phi = 0.8; EllipticFunction f = new EllipticFunction(0.3, 0.4, 0.7, 0.6); f.Reset(0.2, 0.3, 0.8, 0.7); f = new EllipticFunction(0.3, 0.4); f.Reset(0.2, 0.3); double cn, sn, dn; f.sncndn(0.3, out sn, out cn, out dn); f.Delta(sn, cn); f.D(); f.D(phi); f.D(sn, cn, dn); f.Pi(); f.Pi(phi); f.Pi(sn, cn, dn); f.KE(); f.K(); f.H(); f.H(phi); f.H(sn, cn, dn); f.G(); f.G(phi); f.G(sn, cn, dn); f.F(phi); f.F(sn, cn, dn); f.Einv(0.75); f.Ed(60.0); f.E(); f.E(phi); f.E(sn, cn, dn); double tau = 3.1415927 / 10.0; f.deltaEinv(Math.Sin(tau), Math.Cos(tau)); f.deltaD(sn, cn, dn); f.deltaE(sn, cn, dn); f.deltaF(sn, cn, dn); f.deltaG(sn, cn, dn); f.deltaH(sn, cn, dn); f.deltaPi(sn, cn, dn); } catch (Exception xcpt) { MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private bool ZetaInv0(double psi, double lam, out double u, out double v) { bool retval = false; if (psi < -_e * PI / 4 && lam > (1 - 2 * _e) * PI / 2 && psi < lam - (1 - _e) * PI / 2) { // N.B. this branch is normally not taken because psi < 0 is converted // psi > 0 by Forward. // // There's a log singularity at w = w0 = Eu.K() + i * Ev.K(), // corresponding to the south pole, where we have, approximately // // psi = _e + i * pi/2 - _e * atanh(cos(i * (w - w0)/(1 + _mu/2))) // // Inverting this gives: double psix = 1 - psi / _e, lamx = (PI / 2 - lam) / _e; u = Asinh(Sin(lamx) / Hypot(Cos(lamx), Sinh(psix))) * (1 + _mu / 2); v = Atan2(Cos(lamx), Sinh(psix)) * (1 + _mu / 2); u = _Eu.K() - u; v = _Ev.K() - v; } else if (psi < _e * PI / 2 && lam > (1 - 2 * _e) * PI / 2) { // At w = w0 = i * Ev.K(), we have // // zeta = zeta0 = i * (1 - _e) * pi/2 // zeta' = zeta'' = 0 // // including the next term in the Taylor series gives: // // zeta = zeta0 - (_mv * _e) / 3 * (w - w0)^3 // // When inverting this, we map arg(w - w0) = [-90, 0] to // arg(zeta - zeta0) = [-90, 180] double dlam = lam - (1 - _e) * PI / 2, rad = Hypot(psi, dlam), // atan2(dlam-psi, psi+dlam) + 45d gives arg(zeta - zeta0) in range // [-135, 225). Subtracting 180 (since multiplier is negative) makes // range [-315, 45). Multiplying by 1/3 (for cube root) gives range // [-105, 15). In particular the range [-90, 180] in zeta space maps // to [-90, 0] in w space as required. ang = Atan2(dlam - psi, psi + dlam) - 0.75 * PI; // Error using this guess is about 0.21 * (rad/e)^(5/3) retval = rad < _e * taytol_; rad = Cbrt(3 / (_mv * _e) * rad); ang /= 3; u = rad * Cos(ang); v = rad * Sin(ang) + _Ev.K(); } else { // Use spherical TM, Lee 12.6 -- writing atanh(sin(lam) / cosh(psi)) = // asinh(sin(lam) / hypot(cos(lam), sinh(psi))). This takes care of the // log singularity at zeta = Eu.K() (corresponding to the north pole) v = Asinh(Sin(lam) / Hypot(Cos(lam), Sinh(psi))); u = Atan2(Sinh(psi), Cos(lam)); // But scale to put 90,0 on the right place u *= _Eu.K() / (PI / 2); v *= _Eu.K() / (PI / 2); } return(retval); }