34 lines
775 B
C#
34 lines
775 B
C#
using Godot;
|
|
using System;
|
|
|
|
public struct Ellipse
|
|
{
|
|
public double a { get => SemiMajorAxis; set => SemiMajorAxis = value; }
|
|
public double SemiMajorAxis { get; set; }
|
|
|
|
public double e { get => Eccentricity; set => Eccentricity = value; }
|
|
public double Eccentricity { get; set; }
|
|
|
|
public double b => SemiMajorAxis;
|
|
public double SemiMinorAxis => Math.Sqrt(Apisides.max * Apisides.min);
|
|
|
|
private Apisides Apisides => new Apisides(a, e);
|
|
|
|
public Ellipse(double a = 1, double e = 0)
|
|
{
|
|
SemiMajorAxis = a;
|
|
Eccentricity = e;
|
|
}
|
|
}
|
|
|
|
public struct Apisides
|
|
{
|
|
public readonly double min;
|
|
public readonly double max;
|
|
|
|
public Apisides(double a, double e)
|
|
{
|
|
min = a * (1 - e);
|
|
max = a * (1 + e);
|
|
}
|
|
} |