Ejemplo n.º 1
0
def moon_5_latitude_perturbation_terms(Ls, Lm, Ms, Mm, D, F):
    # All & only the terms larger than 0.01 degrees
    # aiming for 1-2 arcmin accuracy.
    # Even with the first term the error is usually under 0.15 degree.
    return (
        -0.173 * sin(F - 2 * D),
        -0.055 * sin(Mm - F - 2 * D),
        -0.046 * sin(Mm + F - 2 * D),
        +0.033 * sin(F + 2 * D),
        +0.017 * sin(2 * Mm + F),
    )
Ejemplo n.º 2
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
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)))
Ejemplo n.º 5
0
def moon_12_longitude_perturbation_terms(Ls, Lm, Ms, Mm, D, F):
    # All & only the terms larger than 0.01 degrees,
    # aiming for 1-2 arcmin accuracy.
    # Even with the first two terms the error is usually under 0.25 degree.
    # These might come from EPL.
    return (
        -1.274 * sin(Mm - 2 * D),      # Evection (Ptolemy)
        +0.658 * sin(2 * D),           # Variation (Tycho Brahe)
        -0.186 * sin(Ms),              # Yearly equation (Tycho Brahe)
        -0.059 * sin(2 * Mm - 2 * D),
        -0.057 * sin(Mm - 2 * D + Ms),
        +0.053 * sin(Mm + 2 * D),
        +0.046 * sin(2 * D - Ms),
        +0.041 * sin(Mm - Ms),
        -0.035 * sin(D),               # Parallactic equation
        -0.031 * sin(Mm + Ms),
        -0.015 * sin(2 * F - 2 * D),
        +0.011 * sin(Mm - 4 * D),
    )
Ejemplo n.º 6
0
 def iterate_once_for_eccentric_anomaly(M, e, E0):
     return E0 - (E0 - (180 / pi) * e * sin(E0) - M) / (1 - e * cos(E0))
Ejemplo n.º 7
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
Ejemplo n.º 8
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)