private void OnValidate(object sender, EventArgs e) { try { double bx, by, bz, bxt, byt, bzt, x, y, z; double time = 1.0; double lon = -86.0; double lat = 32.0; double alt = 30.0; MagneticModel mag = new MagneticModel(m_name, m_path, new Geocentric()); mag = new MagneticModel(m_name, m_path); mag.Field(time, lat, lon, alt, out bx, out by, out bz, out bxt, out byt, out bzt); mag.Field(time, lat, lon, alt, out x, out y, out z); if (bx != x || by != y || bz != z) { throw new Exception("Error in MagneticField.Field"); } MagneticCircle mc = mag.Circle(time, lat, alt); mc.Field(lon, out bx, out by, out bz); mc.Field(lon, out x, out y, out z, out bxt, out byt, out bzt); if (bx != x || by != y || bz != z) { throw new Exception("Error in MagneticCircle.Field (2)"); } MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception xcpt) { MessageBox.Show(xcpt.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
static void Main(string[] args) { try { MagneticModel mag = new MagneticModel("wmm2010", ""); double lat = 27.99, lon0 = 86.93, h = 8820, t = 2012; // Mt Everest { // Slow method of evaluating the values at several points on a circle of // latitude. for (int i = -5; i <= 5; ++i) { double lon = lon0 + i * 0.2; double Bx, By, Bz; mag.Field(t, lat, lon, h, out Bx, out By, out Bz); Console.WriteLine(String.Format("{0} {1} {2} {3}", lon, Bx, By, Bz)); } } { // Fast method of evaluating the values at several points on a circle of // latitude using MagneticCircle. MagneticCircle circ = mag.Circle(t, lat, h); for (int i = -5; i <= 5; ++i) { double lon = lon0 + i * 0.2; double Bx, By, Bz; circ.Field(lon, out Bx, out By, out Bz); Console.WriteLine(String.Format("{0} {1} {2} {3}", lon, Bx, By, Bz)); } } } catch (GeographicErr e) { Console.WriteLine(String.Format("Caught exception: {0}", e.Message)); } }
static void Main(string[] args) { try { MagneticModel mag = new MagneticModel("wmm2010",""); double lat = 27.99, lon0 = 86.93, h = 8820, t = 2012; // Mt Everest { // Slow method of evaluating the values at several points on a circle of // latitude. for (int i = -5; i <= 5; ++i) { double lon = lon0 + i * 0.2; double Bx, By, Bz; mag.Field(t, lat, lon, h, out Bx, out By, out Bz); Console.WriteLine(String.Format("{0} {1} {2} {3}", lon, Bx, By, Bz)); } } { // Fast method of evaluating the values at several points on a circle of // latitude using MagneticCircle. MagneticCircle circ = mag.Circle(t, lat, h); for (int i = -5; i <= 5; ++i) { double lon = lon0 + i * 0.2; double Bx, By, Bz; circ.Field(lon, out Bx, out By, out Bz); Console.WriteLine(String.Format("{0} {1} {2} {3}", lon, Bx, By, Bz)); } } } catch (GeographicErr e) { Console.WriteLine(String.Format("Caught exception: {0}", e.Message)); } }
static void Main(string[] args) { try { MagneticModel mag = new MagneticModel("wmm2010",""); double lat = 27.99, lon = 86.93, h = 8820, t = 2012; // Mt Everest double Bx, By, Bz; mag.Field(t, lat,lon, h, out Bx, out By, out Bz); double H, F, D, I; MagneticModel.FieldComponents(Bx, By, Bz, out H, out F, out D, out I); Console.WriteLine(String.Format("{0} {1} {2} {3}", H, F, D, I)); } catch (GeographicErr e) { Console.WriteLine(String.Format("Caught exception: {0}", e.Message)); } }
static void Main(string[] args) { try { MagneticModel mag = new MagneticModel("wmm2010", ""); double lat = 27.99, lon = 86.93, h = 8820, t = 2012; // Mt Everest double Bx, By, Bz; mag.Field(t, lat, lon, h, out Bx, out By, out Bz); double H, F, D, I; MagneticModel.FieldComponents(Bx, By, Bz, out H, out F, out D, out I); Console.WriteLine(String.Format("{0} {1} {2} {3}", H, F, D, I)); } catch (GeographicErr e) { Console.WriteLine(String.Format("Caught exception: {0}", e.Message)); } }
private void OnUpdate(object sender, EventArgs e) { try { double time = Double.Parse(m_timeTextBox.Text); double lon = Double.Parse(m_longitudeTextBox.Text); double lat = Double.Parse(m_latitudeTextBox.Text); double alt = Double.Parse(m_altitudeTextBox.Text); double bx, by, bz, bxt, byt, bzt; m_magnetic.Field(time, lat, lon, alt, out bx, out by, out bz, out bxt, out byt, out bzt); m_mfXTextBox.Text = bx.ToString(); m_mfYTextBox.Text = by.ToString(); m_mfZTextBox.Text = bz.ToString(); m_mfdXTextBox.Text = bxt.ToString(); m_mfdYTextBox.Text = byt.ToString(); m_mfdZTextBox.Text = bzt.ToString(); } catch (Exception xcpt) { MessageBox.Show(xcpt.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void OnValidate(object sender, EventArgs e) { try { double bx, by, bz, bxt, byt, bzt, x, y, z; double time = 1.0; double lon = -86.0; double lat = 32.0; double alt = 30.0; MagneticModel mag = new MagneticModel(m_name, m_path, new Geocentric()); mag = new MagneticModel(m_name, m_path); mag.Field(time, lat, lon, alt, out bx, out by, out bz, out bxt, out byt, out bzt); mag.Field(time, lat, lon, alt, out x, out y, out z); if (bx != x || by != y || bz != z) throw new Exception("Error in MagneticField.Field"); MagneticCircle mc = mag.Circle(time, lat, alt); mc.Field(lon, out bx, out by, out bz); mc.Field(lon, out x, out y, out z, out bxt, out byt, out bzt); if (bx != x || by != y || bz != z ) throw new Exception("Error in MagneticCircle.Field (2)"); MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception xcpt) { MessageBox.Show(xcpt.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } }