Beispiel #1
0
 def from_eccentric(cls, eccentric_anomaly, eccentricity):
     # This would be easy to understand from a simple diagram.
     x = cos(eccentric_anomaly) - eccentricity
         # == radius * cos(θ)
     y = sin(eccentric_anomaly) * sqrt(1 - eccentricity ** 2)
         # == radius * sin(θ)
     self = cls.__new__(cls)
     self.__init__(x, y)
     return self
Beispiel #2
0
def position_from_plane_of_orbit_to_ecliptic(r, θ, Ω, i, ω):
    # TODO: break this down to easily understood operations
    #   using angle sum formulas etc.
    #                           _ _     _ _     _
    # cos(-x) = cos(x)        1 ┆╳ ╲   ╱┆╳ ╲   ╱┆ cos
    # sin(-x) = -sin(x)       0 ╱┄╲┄╲┄╱┄╱┄╲┄╲┄╱┄╱ sin
    # sin(x) = cos(x - 90)   -1 ┆  ╲_╳_╱┆  ╲_╳_╱┆
    # sin(x - 90) = -cos(x)    -2pi     0       2pi
    #
    # a - b = a + (-b)
    # cos(a + b) = cos(a)cos(b) - sin(a)sin(b)
    # cos(a - b) = cos(a)cos(b) + sin(a)sin(b)
    # sin(a + b) = sin(a)cos(b) + cos(a)sin(b)
    # sin(a - b) = sin(a)cos(b) - cos(a)sin(b)

    (xeclip, yeclip, zeclip) = (
        r * (
            cos(Ω) * cos(θ + ω)
            - sin(Ω) * sin(θ + ω) * cos(i)
        ),
        r * (
            sin(Ω) * cos(θ + ω)
            + cos(Ω) * sin(θ + ω) * cos(i)
        ),
        r * sin(θ + ω) * sin(i),
    )
    return (xeclip, yeclip, zeclip)
Beispiel #3
0
def eccentric_anomaly_first_approximation(mean_anomaly, eccentricity):
    """
    This truncated Taylor series is claimed accurate enough for a small
    eccentricity such as that of the Sun-Earth orbit (0.017).
    Properly the eccentric anomaly is the solution E
    of Kepler's equation in mean anomaly M and eccentricity e:
        M = E - e sin(E).
    Thanks to Paul Schlyter himself for clarifying this in a
    private email which, frankly, I have not yet fully analyzed.
    """
    return rev(
        mean_anomaly
        + (180 / pi) * eccentricity * sin(mean_anomaly)
        * (1 + eccentricity * cos(mean_anomaly)))
Beispiel #4
0
def moon_2_distance_perturbation_terms(Ls, Lm, Ms, Mm, D, F):
    # all & only the terms larger than 0.1 Earth radii
    return (
        -0.58 * cos(Mm - 2 * D),
        -0.46 * cos(2 * D),
    )
Beispiel #5
0
 def iterate_once_for_eccentric_anomaly(M, e, E0):
     return E0 - (E0 - (180 / pi) * e * sin(E0) - M) / (1 - e * cos(E0))
Beispiel #6
0
 def from_polar(cls, p):
     x = p.r * cos(p.θ)
     y = p.r * sin(p.θ)
     self = cls.__new__(cls)
     self.__init__(x, y)
     return self
Beispiel #7
0
def cartesian2d_in_plane_of_orbit(eccentric_anomaly, eccentricity, distance):
    (x, y) = (
        distance * (cos(eccentric_anomaly) - eccentricity),
        distance * sqrt(1 - eccentricity ** 2) * sin(eccentric_anomaly),
    )
    return (x, y)