Laden...

Winkel und Kugelkoordinaten

Erstellt von MarsStein vor 14 Jahren Letzter Beitrag vor 14 Jahren 3.622 Views
MarsStein Themenstarter:in
3.170 Beiträge seit 2006
vor 14 Jahren
Winkel und Kugelkoordinaten

Hallo Community,

im Rahmen eines privaten Projektes (Bibliothek zur Erstellung von Sternkarten) habe ich zwei Strukturen implementiert, die den Umgang mit Winkeln und Kugelkoordinaten auf der Einheitskugel kapseln, und eine Klasse, die das Resultat eines Vergleichs von zwei Winkeln darstellt. Das alles eigent sich sowohl für astronomische als auch geografische Berechnungen. Erstellt wurden sie unter Linux/Mono für das 2.0-Framework, und laufen natürlich auch unter .NET ab 2.0.

Da die Klassen mittlerweile recht umfangreich sind, gibt es hier nur eine Übersicht über die public Member einzelnen Klassen. Näheres können Interessierte den XML-Kommentaren oder der beigefügten HTML-Dokumentation entnehmen (erstellt mit monodocer). Sorry daß die Dokumentation vollständig in Englisch ist, aber das habe ich (fast) schon immer so gehalten.

Die Member, die auf "R2" enden, betrachten den Winkel im Bereich von -180° bis 180°, alle anderen Member und die Operatoren arbeiten im Bereich von 0° bis 360°.

[Serializable]
public struct Angle: IComparable, IEquatable<Angle>, IFormattable, ISerializable

{

  #region static special angles

  public static Angle FullCircle { get; }
  public static Angle StraightAngle { get; }
  public static Angle RightAngle { get; }
  public static Angle ZeroAngle { get; }

  #endregion

  #region static creation methods


  public static Angle FromRadians(double radians); // Bogenmaß
  public static Angle FromDegrees(double degrees); // Grad
  public static Angle FromDegrees(int degrees, double arcminutes);
  public static Angle FromDegrees(int degrees, int arcminutes, double arcseconds)

  public static Angle FromGons(double gons); // Neugrad
  public static Angle FromHours(double hours); // Stundenwinkel
  public static Angle FromHours(int hours, double minutes);
  public static Angle FromHours(int hours, int minutes, double seconds);
  public static Angle FromSine(double sine);
  public static Angle FromCosine(double cosine);
  public static Angle FromCartesianPoint(double x, double y) // Winkel zwische x-Achse und der
                                                             // Ursprungsgeraden durch (x;y)

  #endregion


  #region operators

  public static bool operator == (Angle test, Angle other);
  public static bool operator != (Angle test, Angle other);
  public static bool operator > (Angle test, Angle other);
  public static bool operator >= (Angle test, Angle other);
  public static bool operator < (Angle test, Angle other);
  public static bool operator <= (Angle test, Angle other);
  public static Angle operator + (Angle a, Angle b);
  public static Angle operator - (Angle a, Angle b);
  public static Angle operator * (Angle a, int b);
  public static Angle operator * (int b, Angle a);
  public static Angle operator * (Angle a, double b);
  public static Angle operator * (double b, Angle a);
  public static Angle operator / (Angle a, int b);
  public static Angle operator / (Angle a, double b);
  public static Angle operator - (Angle a);

  #endregion


  #region properties


  public double Radians { get; } // Bogenmaß
  public double RadiansR2 { get; }
  public double Degrees { get; } // Grad
  public double DegreesR2 { get; }
  public double Gons { get; } // Neugrad
  public double GonsR2 { get; }
  public double Hours { get; } // Stundenwinkel
  public double HoursR2{ get; }

  public double Sin { get; }
  public double Cos { get; }
  public double Tan{ get; }
  public double SinH { get; }
  public double CosH { get; }
  public double TanH { get; }
  public Angle Explement { get; }
  public Angle Supplement { get; }
  public Angle Antipodal { get; }
  public bool IsZeroAngle { get; }
  public bool IsAcuteAngle { get; }
  public bool IsAcuteAngleR2 { get; }
  public bool IsRightAngle { get; }
  public bool IsRightAngleR2 { get; }
  public bool IsObtuseAngle { get; }
  public bool IsObtuseAngleR2 { get; }
  public bool IsStraightAngle { get; }
  public bool IsReflexAngle { get; }

  #endregion


  #region split methods


  public void SplitDegrees(out int degrees, out double arcminutes);
  public void SplitDegreesR2(out int degrees, out double arcminutes);
  public void SplitDegrees(out int degrees, out int arcminutes, out double arcseconds);
  public void SplitDegreesR2(out int degrees, out int arcminutes, out double arcseconds);
  public void SplitHours(out int hours, out double minutes);
  public void SplitHoursR2(out int hours, out double minutes);
  public void SplitHours(out int hours, out int minutes, out double seconds);
  public void SplitHoursR2(out int hours, out int minutes, out double seconds);

  #endregion


  #region manipulation methods


  public Angle AddRadians(double radians);
  public Angle AddDegrees(double degrees);
  public Angle AddDegrees(int deg, double min);
  public Angle AddDegrees(int deg, int min, double sec);
  public Angle AddGons(double gons);
  public Angle AddHours(double hours);
  public Angle AddHours(int hr, double min);
  public Angle AddHours(int hr, int min, double sec);

  #endregion


  #region comparison methods


  public AngleCompareResult CompareTo(Angle comp);

  #endregion


  #region string methods


  public override string ToString()

  public string ToString(String format); // mit einer ganzen Reihe Formatierungen
  public string ToString(String format, IFormatProvider fp);

  #endregion


  #region interface implemetations

  public override int GetHashCode();
  public override bool Equals(object obj)

  bool IEquatable<Angle>.Equals(Angle other);
  int IComparable.CompareTo(object obj);

  #endregion
}

public class AngleCompareResult

{

  #region properties

  public bool IsEqual { get; }
  public bool IsGreater { get; }
  public bool IsGreaterR2  { get; }
  public bool IsGreaterOrEqualR2 { get; }
  public bool IsLower { get; }
  public bool IsLowerOrEqual { get; }
  public bool IsLowerR2  { get; }
  public bool IsLowerOrEqualR2 { get; }
  public bool IsAheadOf { get; }
  public bool IsAheadOfOrEqual { get; }
  public bool IsBehind { get; }
  public bool IsBehindOrEqual { get; }

  #endregion

}

[Serializable]

public struct SphericalPoint: ISerializable

{
  #region static special SphericalPoints


  public static SphericalPoint PositivePole { get; }
  public static SphericalPoint NegativePole { get; }
  public static SphericalPoint Zero { get; }

  #endregion

  #region Construction


  public SphericalPoint(Angle initLongitude, Angle initElevation)


  #endregion


  #region operators

  public static bool operator == (SphericalPoint a, SphericalPoint b);
  public static bool operator != (SphericalPoint a, SphericalPoint b);

  #endregion


  #region properties

  public Angle Longitude { get; }
  public Angle Elevation { get; }
  public bool IsPositivePole { get; }
  public bool IsNegativePole { get; }

  #endregion


  #region manipulation methods


  public SphericalPoint SetLongitude(Angle newLongitude);
  public SphericalPoint SetElevation(Angle newElevation);
  public SphericalPoint AddLongitude(Angle addLongitude);
  public SphericalPoint AddElevation(Angle addElevation);

  #endregion

  #region calculations

  // mit den nächsten beiden Membern lässt sich die Achse über das nautische Dreieck
  // transformieren. Die Doku reicht aber vermutlich noch nicht aus -> ich arbeite daran!
  public enum OffsetBase
  public SphericalPoint TransformSystem(SphericalPoint destPoleInSource,  Angle originOffset,
                                        OffsetBase opt, bool reverseLongit);
  public Angle DistanceTo(SphericalPoint sp);

  #endregion

  #region interface implementations


  public override bool Equals(object obj);
  public override int GetHashCode();

  #endregion
}

Schlagwörter: Winkel, Kugelkoordinaten, Winkelfunktionen, Sinus, Cosinus, Tangens, Sphere, Sphäre, Kugel, Kugelgeometrie, Kugel, Einheitskugel, Einheitskreis, Astronomie, Geographie, Himmelsmechanik, astronomisch, geografisch, geographisch, sphärisch, Koordinaten
Viel Spaß beim "angulieren". Bei Bugs oder Fragen einfach fragen -> gerne auch per PM.

Gruß, MarsStein

Non quia difficilia sunt, non audemus, sed quia non audemus, difficilia sunt! - Seneca