public OrbitsPresenter(DateTimeOffset start, DateTimeOffset end) { Orbits = new OrbitsCollection(start, end); Presenter = AnglePresenter.Natural; TimeTranslator = TimeToAngle.Default; PriceTranslator = PriceToAngle.DimeNatural; Controller = new Dictionary <PlanetId, PlanetManager>(); for (PlanetId id = PlanetId.SE_SUN; id <= PlanetId.SE_PLUTO; id++) { PlanetManager manager = new PlanetManager(id); Controller.Add(id, manager); //manager.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(planetsOrbitsShownChanged); } }
public List <IPlanetEvent> this[SeFlg centric, PlanetId star1] { get { List <IPlanetEvent> result = new List <IPlanetEvent>(); foreach (KeyValuePair <PlanetEventFlag, Dictionary <PlanetId, List <IPlanetEvent> > > kvp in centric == SeFlg.GEOCENTRIC ? GeoAspectarian : HelioAspectarian) { if (kvp.Value.ContainsKey(star1)) { result.AddRange(kvp.Value[star1]); } } return(result); } }
private static void eclipseTest3() { int year = 1927; DateTimeOffset date = new DateTimeOffset(year, 5, 1, 0, 0, 0, TimeSpan.Zero); List <SeFlg> flags = new List <SeFlg>() { (SeFlg)0, SeFlg.GEOCENTRIC, SeFlg.GEOCENTRIC | SeFlg.SEFLG_TRUEPOS, SeFlg.EQUATORIALBASED, SeFlg.HELIOCENTRIC, SeFlg.HELIOCENTRIC | SeFlg.SEFLG_EQUATORIAL }; Position pos = null; PlanetId star = PlanetId.SE_URANUS; while (true) { Console.WriteLine("On " + date.ToString()); foreach (SeFlg flg in flags) { pos = Ephemeris.PositionOf(date, star, flg); Console.WriteLine("{0}: Long={1}, Lat={2}", flg, pos.Longitude, pos.Latitude); } Console.WriteLine("Input the date: "); string line = Console.ReadLine(); if (!DateTimeOffset.TryParse(line, out date)) { return; } Console.WriteLine("Input the planet: "); PlanetId id = PlanetId.SE_URANUS; line = Console.ReadLine(); if (Planet.TryParseId(line, out id)) { star = id; } } }
private void comboFocusedStar_SelectedIndexChanged(object sender, EventArgs e) { string name = comboFocusedStar.SelectedItem.ToString(); foreach (KeyValuePair <PlanetId, Planet> kvp in Planet.All) { if (kvp.Value.Name != name) { continue; } FocusedPlanet = kvp.Key; synchFocusedAspect(); break; } }
private void checkBoxAspect_CheckedChanged(object sender, EventArgs e) { comboBoxImportance.Enabled = comboBoxConcernedStar.Enabled = checkBoxAspect.Checked; if (triggerEvent && AspectsConcernedChanged != null) { AspectImportance importance = (AspectImportance)Enum.Parse(typeof(AspectImportance), comboBoxImportance.SelectedItem.ToString()); PlanetId star1 = (comboBoxConcernedStar.SelectedIndex == comboBoxConcernedStar.Items.Count - 1) ? PlanetId.SE_ECL_NUT : theParent.CurrentEphemeris.Luminaries[comboBoxConcernedStar.SelectedIndex]; PlanetId star2 = (comboBoxAnother.SelectedIndex == comboBoxAnother.Items.Count - 1) ? PlanetId.SE_ECL_NUT : theParent.CurrentEphemeris.Luminaries[comboBoxAnother.SelectedIndex]; AspectsConcernedChanged(checkBoxAspect.Checked, star1, star2, importance); } }
private void textBoxOffset_Leave(object sender, EventArgs e) { if (triggerEvent && PlanetOffsetSelected != null && comboBoxFocused.SelectedIndex != -1) { PlanetId id = theParent.CurrentEphemeris.Luminaries[comboBoxFocused.SelectedIndex]; int degree = 0; if (int.TryParse(textBoxOffset.Text, out degree)) { PlanetOffsetSelected(id, new List <int> { degree }, true); } } textBoxOffset.Text = ""; }
public static double MovementOf(PlanetId id, bool isHeliocentric, DateTimeOffset time1, DateTimeOffset time2) { Position pos1, pos2; if (time1 == time2) { return(0); } else if (time1 > time2) { DateTimeOffset tempTime = time1; time1 = time2; time2 = tempTime; } TimeSpan duration = time2 - time1; double period = duration.TotalDays / Planet.OrbitalPeriods[id]; double round = period * 360; if (isHeliocentric) { pos1 = Ephemeris.HeliocentricPositionOf(time1, id); pos2 = Ephemeris.HeliocentricPositionOf(time2, id); double temp = (360 + pos2.Longitude - pos1.Longitude) % 360; return(Math.Round((round - temp) / 360) * 360 + temp); } else { pos1 = Ephemeris.GeocentricPositionOf(time1, id); pos2 = Ephemeris.GeocentricPositionOf(time2, id); double temp = pos2.Longitude - pos1.Longitude; if (temp < 0 && (period > 0.4 || duration.Days > Planet.RetrogradePeriods[id])) { temp += 360; } else if (temp > 300 && period < 0.4) { temp -= 360; } return(Math.Round((round - temp) / 360) * 360 + temp); } }
private string zedLongTerm_PointValueEvent(ZedGraphControl sender, GraphPane pane, CurveItem curve, int iPt) { LineItem line = curve as LineItem; if (line == null) { return(""); } string name = curve.Label.Text; PlanetId id = Planet.GlyphToPlanetId[name[0]]; if (line.Symbol.Type == SymbolType.None) { PointPair pt = curve.Points[iPt]; DateTimeOffset time = new DateTimeOffset(DateTime.FromOADate(pt.X), TimeSpan.Zero); return(string.Format("{0}: {1} @ {2:F1}", time.ToString("MM-dd"), name, pt.Y)); } else { PlanetEventFlag category = (from kvp in defaultEventSymbolType where kvp.Value == line.Symbol.Type select kvp.Key).FirstOrDefault(); if (category != PlanetEventFlag.AspectCategory) { IPlanetEvent evt = TheAspectarian[category][id][iPt]; return(evt.ToString()); } else { PointPair pt = curve.Points[iPt]; DateTimeOffset time = new DateTimeOffset(DateTime.FromOADate(pt.X), TimeSpan.Zero); IPlanetEvent closestEvt = (from one in TheAspectarian[category][id] orderby Math.Abs((one.When - time).TotalDays) select one ).First(); return(closestEvt.ToString()); } } }
public Form1() { InitializeComponent(); DateTime date = dateTimePicker1.Value.Date; start = new DateTimeOffset(date.Year, date.Month, date.Day, 0, 0, 0, TimeSpan.Zero); for (PlanetId id = PlanetId.SE_SUN; id <= PlanetId.SE_PLUTO; id++) { if (id == PlanetId.SE_MOON) { continue; } comboBoxPlanets.Items.Add(id.ToString()); } comboBoxPlanets.SelectedIndex = 0; }
private void buttonSet_Click(object sender, EventArgs e) { if (comboBoxFocused.SelectedIndex == -1) { return; } PlanetId id = theParent.CurrentEphemeris.Luminaries[comboBoxFocused.SelectedIndex]; foreach (Control cn in panelAspects.Controls) { if (cn is CheckBox) { CheckBox cb = cn as CheckBox; cb.Checked = false; } } }
private void comboBoxInterior_SelectedIndexChanged(object sender, EventArgs e) { comboBoxExterior.Items.Clear(); interior = (comboBoxInterior.SelectedItem as Planet).Id; foreach (KeyValuePair <PlanetId, Planet> kvp in Planet.All) { if (kvp.Key <= interior) { continue; } comboBoxExterior.Items.Add(kvp.Value); } comboBoxExterior.SelectedIndex = 0; }
private static void MarsTest2(PlanetId id) { Rectascension destination = new Rectascension(346.7); DateTimeOffset since = new DateTimeOffset(1951, 3, 14, 1, 1, 0, TimeSpan.Zero); for (int i = 0; i < 10; i++) { destination = new Rectascension(destination.Degrees + i * 330); DateTimeOffset date = Ephemeris.DateOfPlanetPosition(id, since, destination); double jul_ut = Utilities.ToJulianDay(date); Position actual = Utilities.GeocentricPositionOfJulian(jul_ut, id); double dif = actual.Longitude - destination.Degrees; Console.WriteLine("{0}: {1} on {2}, dif = {3:F4}", date, id, actual.ToString("Astro0", null), dif); since = date + TimeSpan.FromDays(60); } }
private void buttonTest1_Click(object sender, EventArgs e) { DateTimeOffset since = new DateTimeOffset(2001, 1, 1, 0, 0, 0, TimeSpan.Zero); int count = 0; double longitude = 0; DateTime start = DateTime.Now; for (int i = 0; i < 360; i++) { DateTimeOffset date = since.AddDays(i); for (PlanetId id = PlanetId.SE_SUN; id <= PlanetId.SE_PLUTO; id++) { longitude = Ephemeris.Geocentric[date, id].Longitude; count++; } } MessageBox.Show(String.Format("{0}ms elapsed for {1} position calculation.", (DateTime.Now - start).TotalMilliseconds, count)); }
private void loadNodeApsides(PlanetId star) { double[] xnasc = new double[6]; double[] xndsc = new double[6]; double[] xperi = new double[6]; double[] xaphe = new double[6]; String errorMsg = ""; Dictionary <OrbitInfoType, List <Double> > planetOrbits = AllOrbits[star]; for (OrbitInfoType type = OrbitInfoType.Ascending; type <= OrbitInfoType.ApogeeVelocities; type++) { planetOrbits.Add(type, new List <double>()); } double end = Utilities.ToJulianDay(End); for (double date = Utilities.ToJulianDay(Start); date <= end; date += SparsedInterval) { if (Utilities.swe_nod_aps_ut(date, star, SeFlg.SEFLG_SPEED | SeFlg.SEFLG_HELCTR, 0, xnasc, xndsc, xperi, xaphe, errorMsg) == SeFlg.ERR) { throw new Exception(); } else { planetOrbits[OrbitInfoType.Ascending].Add(xnasc[0]); planetOrbits[OrbitInfoType.AscendingLatitude].Add(xnasc[1]); planetOrbits[OrbitInfoType.AscendingVelocities].Add(xnasc[3]); planetOrbits[OrbitInfoType.Descending].Add(xndsc[0]); planetOrbits[OrbitInfoType.DescendingLatitude].Add(xndsc[1]); planetOrbits[OrbitInfoType.DescendingVelocities].Add(xndsc[3]); planetOrbits[OrbitInfoType.Perigee].Add(xperi[0]); planetOrbits[OrbitInfoType.PerigeeLatitude].Add(xperi[1]); planetOrbits[OrbitInfoType.PerigeeVelocities].Add(xperi[3]); planetOrbits[OrbitInfoType.Apogee].Add(xaphe[0]); planetOrbits[OrbitInfoType.ApogeeLatitude].Add(xaphe[1]); planetOrbits[OrbitInfoType.ApogeeVelocities].Add(xaphe[3]); } } }
public string HelioEventsSummaryOf(PlanetId id) { List <IPlanetEvent> events = this[SeFlg.HELIOCENTRIC, id]; if (events == null || events.Count == 0) { return(""); } StringBuilder sb = new StringBuilder(); foreach (IPlanetEvent evt in events) { sb.AppendFormat("{0}, ", evt.ShortDescription); } sb.Remove(sb.Length - 2, 2); return(sb.ToString()); }
public static void CalcPhenomenon(DateTime utcMoment, PlanetId ipl, SeFlg flag) { double jul_ut = ToJulianDay(utcMoment); double[] result = new double[20]; String errorMsg = ""; SeFlg retFlag = SeFlg.ERR; retFlag = swe_pheno_ut(jul_ut, ipl, flag, result, errorMsg); if (retFlag == SeFlg.ERR) { DateTime utc = SweWrapper.UtcFromJulianDay(jul_ut); Console.WriteLine(String.Format("Error for {0}@{1} with Flag of {2}: {3}", ipl, utc, SeFlg.DEFAULT, errorMsg)); } else { /// * attr[0] = phase theAngle (earth-planet-sun) /// * attr[1] = phase (illumined fraction of disc) /// * attr[2] = elongation of planet /// * attr[3] = apparent diameter of disc /// * attr[4] = apparent magnitude /// * attr[5] = geocentric horizontal parallax (Moon) DateTime utc = SweWrapper.UtcFromJulianDay(jul_ut); StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0} at {1}", ipl, utc); sb.AppendFormat("PhaseAngle = {0}, Phase={1}, Elongation={2}, Diameter={3}, Magnitude={4}, Parallax={5}", result[0], result[1], result[2], result[3], result[4], result[5]); for (int i = 6; i < 20; i++) { sb.AppendFormat("result[{0}] = {1}\t", i, result[i]); if ((i - 6) % 5 == 4) { sb.AppendLine(); } } Console.Write(sb.ToString()); } }
public void AddCurve(PlanetId id, OrbitInfoType kind) { if (!IsCurveAdded(id, kind)) { OrbitSpec spec = this[id, kind]; CurveItem curve = null; if (kind == OrbitInfoType.Longitude || (kind >= OrbitInfoType.Ascending && kind <= OrbitInfoType.Apogee)) { curve = Frame.CurveOf(spec); } else if (kind.ToString().EndsWith("Latitude")) { curve = spec.OriginalCurve; curve.IsY2Axis = true; thePane.Y2Axis.IsVisible = true; Double max = Math.Max(Math.Abs(spec.MaxY), Math.Abs(spec.MinY)); if (max > thePane.Y2Axis.Scale.Max) { SetY2Scale(max); } } else { thePane.Y2AxisList[1].IsVisible = true; curve = spec.OriginalCurve; curve.IsY2Axis = true; curve.YAxisIndex = 1; Double max = Math.Max(Math.Abs(spec.MaxY), Math.Abs(spec.MinY)); if (max > thePane.Y2AxisList[1].Scale.Max) { SetY3Scale(max); } } AddCurve(curve); } }
public static int CodeOf(PlanetId pA, PlanetId pB) { if (pA <= pB) { int temp = (int)pA; temp = temp << 8; temp += (int)pB; return(temp); } else { int temp = (int)pB; temp = temp << 8; temp += (int)pA; return(temp); } //return (pA <= pB) ? // (((int)pA) << 8 + ((int)pB)) // : (((int)pB) << 8 + ((int)pA)); }
public static double LongitudeDegreeOf(double jul_ut, PlanetId id) { double[] result = new double[6]; String errorMsg = ""; SeFlg retFlag = SeFlg.ERR; if (id < PlanetId.SE_NORTHNODE) { retFlag = swe_calc_ut(jul_ut, id, SeFlg.DEFAULT, result, errorMsg); if (retFlag != SeFlg.ERR) { //if (retFlag != flag) // Console.WriteLine(((SeFlg)retFlag).ToString()); return(result[0]); } } return(Longitude.NullDegrees); }
private void comboBoxFocused_SelectedIndexChanged(object sender, EventArgs e) { PlanetId id = theParent.CurrentEphemeris.Luminaries[comboBoxFocused.SelectedIndex]; foreach (Control cnt in panelAspects.Controls) { CheckBox cb = cnt as CheckBox; if (cb == null) { continue; } int aspectDegree = int.Parse(cb.Text); if (theParent.Curves.ContainsKey(id)) { cb.Checked = theParent.Curves[id].ContainsKey(aspectDegree) || theParent.Curves[id].ContainsKey(360 - aspectDegree); } } }
public static bool TryParseId(string s, out PlanetId result) { if (Enum.IsDefined(typeof(PlanetId), s)) { result = (PlanetId)Enum.Parse(typeof(PlanetId), s, true); return(true); } else { foreach (string value in Enum.GetNames(typeof(PlanetId))) { if (value.Equals(s, StringComparison.OrdinalIgnoreCase)) { result = (PlanetId)Enum.Parse(typeof(PlanetId), value); return(true); } } result = PlanetId.SE_ECL_NUT; return(false); } }
public List <IPlanetEvent> this[SeFlg centric, PlanetEventFlag category, PlanetId id] { get { if ((centric != SeFlg.HELIOCENTRIC && centric != SeFlg.GEOCENTRIC) || !PlanetEvent.PlanetEventSymbolToCategory.ContainsValue(category)) { throw new ArgumentOutOfRangeException(); } if (centric == SeFlg.GEOCENTRIC && GeoAspectarian.ContainsKey(category) && GeoAspectarian[category].ContainsKey(id)) { return(GeoAspectarian[category][id]); } else if (centric == SeFlg.HELIOCENTRIC && HelioAspectarian.ContainsKey(category) && HelioAspectarian[category].ContainsKey(id)) { return(HelioAspectarian[category][id]); } return(null); } }
public PlanetId NearestPlanet(float angle, float distance) { //float sectorAngle = 180f / (Container.Calculator.Edges); List <KeyValuePair <PlanetId, AngledLabel> > around = (from kvp in Positions let label = kvp.Value where Math.Abs(label.Angle - angle) < 5f && Math.Abs(label.Distance - distance) < 0.5 select kvp).ToList(); if (around.Count == 0) { return(PlanetId.SE_ECL_NUT); } PlanetId nearest = (from kvp in around let dist = Container.DistanceBetween(distance, angle, kvp.Value.Distance, kvp.Value.Angle) orderby dist where dist <= DirectFont.Height / 2f select kvp.Key).FirstOrDefault(); return(nearest); }
public static List <Relation> RelationsWithin(MatchRules period, PlanetId oneParty) { DateTimeOffset startDate = period.Since.UtcDateTime.Date; DateTimeOffset endDate = period.Until.UtcDateTime.Date; List <Relation> allRelations = new List <Relation>(); for (DateTimeOffset date = startDate; date < endDate; date += TimeSpan.FromDays(1)) { allRelations.AddRange(RelationsOn(date, oneParty)); } if (endDate - startDate <= TimeSpan.FromDays(1)) { return(allRelations); } allRelations = Optimize(allRelations); return(allRelations); }
public Position PositionOf(List <Position> positions, PlanetId id) { if (Luminous.Contains(id)) { int index = (int)id; Position result = null; if (index < positions.Count) { result = positions[index]; } else { index = Luminous.IndexOf(id); result = positions[index]; } if (result.Owner == id) { return(result); } else { throw new Exception(); } } else { for (int i = Luminous.Count; i < positions.Count; i++) { Position pos = positions[i]; if (pos.Owner == id) { return(pos); } } } return(null); }
private void aspectCheckedChanged(object sender, EventArgs e) { if (triggerEvent && PlanetOffsetSelected != null && comboBoxFocused.SelectedIndex != -1 && sender is CheckBox) { PlanetId id = theParent.CurrentEphemeris.Luminaries[comboBoxFocused.SelectedIndex]; CheckBox cb = sender as CheckBox; int offset = int.Parse(cb.Text); List <int> aspects = new List <int>(); aspects.Add(offset); if (!aspects.Contains(360 - offset)) { aspects.Add(360 - offset); } PlanetOffsetSelected(id, aspects, cb.Checked); } }
public double this[PlanetId id, MovementFlag flag] { get { if (id > PlanetId.SE_PLUTO && id != PlanetId.SE_EARTH) { return(0); } else if (Time1 == Time2) { return(0); } switch (flag) { case MovementFlag.GeoLongitudeMovement: return(LongitudeChanges[Ephemeris.GeocentricLuminaries.IndexOf(id)]); case MovementFlag.GeoLatitudeMovement: return(LatitudeChanges[Ephemeris.GeocentricLuminaries.IndexOf(id)]); case MovementFlag.GeoDistanceMovement: return(DistanceChanges[Ephemeris.GeocentricLuminaries.IndexOf(id)]); case MovementFlag.HelioLongitudeMovement: return(LongitudeChanges[HelioIndex + Ephemeris.HeliocentricLuminaries.IndexOf(id)]); case MovementFlag.HelioLatitudeMovement: return(LatitudeChanges[HelioIndex + Ephemeris.HeliocentricLuminaries.IndexOf(id)]); case MovementFlag.HelioDistanceMovement: return(DistanceChanges[HelioIndex + Ephemeris.HeliocentricLuminaries.IndexOf(id)]); default: return(0); } } }
/// <summary> /// Display the selected curves. /// </summary> private void displayCurves() { foreach (Control starControl in panelStars.Controls) { if (starControl is CheckBox) { CheckBox cb = starControl as CheckBox; int index = panelStars.Controls.IndexOf(starControl); PlanetId id = CurrentEphemeris.Luminaries[index]; char symbol = Planet.Glyphs[id]; if (cb.Checked) { showPlanetCurves(id); } else { hidePlanetCurves(id); } } } zedLongTerm.Invalidate(); }
private TextObj lableOf(string name, double x, double y) { TextObj label = null; label = new TextObj(name, x, y); label.Location.AlignV = AlignV.Center; if (Planet.GlyphToPlanetId.ContainsKey(name[0])) { PlanetId id = Planet.GlyphToPlanetId[name[0]]; label.FontSpec.FontColor = Planet.PlanetsColors[id][0]; } else { label.FontSpec.FontColor = Color.Gray; } label.Location.AlignH = AlignH.Left; label.FontSpec.Fill.IsVisible = false; label.FontSpec.Border.IsVisible = false; label.FontSpec.Size = 6f; return(label); }
/// <summary> /// Turn on/off the line related to the specific star /// </summary> /// <param name="sender">Sender of the event</param> /// <param name="e">param</param> private void checkBoxStar_CheckedChanged(object sender, EventArgs e) { CheckBox cb = sender as CheckBox; if (cb == null) { return; } int index = panelStars.Controls.IndexOf(cb); PlanetId id = CurrentEphemeris.Luminaries[index]; if (cb.Checked) { showPlanetCurves(id); } else { hidePlanetCurves(id); } zedLongTerm.Invalidate(); }