def __init__(
        self,
        body: Body,
        periapsis: Quantity,
        energy: Quantity,
        rot: Optional[Quaternion] = None,
    ):
        assert periapsis.has_units(METERS)
        assert energy.has_units(METERS**2 / SECS**2)

        # For a periapsis P, not all energies are allowed. The smallest allowed
        # energy is a circular orbit. From E we can find the semimajor axis
        # so we can tell whether the apsis we have is the peri- or apo-apsis.
        # We only have to worry about this when the orbit is elliptical.
        if energy.value < 0:
            sma = -body.mu / 2 / energy
            if periapsis > sma:
                periapsis = 2 * sma - periapsis

        self.body = body
        self.periapsis = periapsis
        self.energy = energy
        self.rot = rot or Quaternion(1, 0, 0, 0)
Beispiel #2
0
    def adjust_height(self, distance: Quantity, sea_level: bool = True) -> Quantity:
        assert distance.has_units(METERS)

        if sea_level:
            return distance + self.radius
        return distance
Beispiel #3
0
    def escape_velocity(self, r: Quantity) -> Quantity:
        assert r.has_units(METERS)

        return (2 * self.mu / r).root(2)
Beispiel #4
0
    def __init__(self, mu: Quantity, radius: Quantity):
        assert mu.has_units(_MU_UNITS)
        assert radius.has_units(METERS)

        self.mu = mu
        self.radius = radius