Beispiel #1
0
 def _label_text(self, entity: Entity) -> str:
     label = entity.name
     if entity.broken:
         label += ' [BROKEN]'
     label += '\nFuel: ' + common.format_num(entity.fuel, " kg")
     if entity.landed_on == AYSE:
         label += '\nDocked'
     elif entity.landed():
         label += '\nLanded'
     return label
Beispiel #2
0
 def _label_text(self, entity: Entity, state: PhysicsState) -> str:
     label = super()._label_text(entity, state)
     if entity.broken:
         label += ' [BROKEN]'
     label += '\nFuel: ' + common.format_num(entity.fuel, " kg")
     if entity.landed_on == common.AYSE:
         label += '\nDocked'
     elif entity.landed():
         label += '\nLanded'
     return label
Beispiel #3
0
    def _create_wtexts(self):
        vpython.canvas.get_selected().caption += "<table>\n"
        self._wtexts: List[TableText] = []

        self._wtexts.append(
            TableText("Simulation time",
                      lambda state: datetime.fromtimestamp(
                          state.timestamp, common.TIMEZONE).strftime('%x %X'),
                      "Current time in simulation",
                      new_section=False))
        self._wtexts.append(
            TableText("Orbit speed",
                      lambda state: common.format_num(
                          calc.orb_speed(state.craft_entity(),
                                         state.reference_entity()), " m/s"),
                      "Speed required for circular orbit at current altitude",
                      new_section=False))

        self._wtexts.append(
            TableText(
                "Periapsis",
                lambda state: common.format_num(calc.periapsis(
                    state.craft_entity(), state.reference_entity()) / 1000,
                                                " km",
                                                decimals=3),
                "Lowest altitude in naïve orbit around reference",
                new_section=False))

        self._wtexts.append(
            TableText(
                "Apoapsis",
                lambda state: common.format_num(calc.apoapsis(
                    state.craft_entity(), state.reference_entity()) / 1000,
                                                " km",
                                                decimals=3),
                "Highest altitude in naïve orbit around reference",
                new_section=False))

        self._wtexts.append(
            TableText(
                # The H in HRT stands for Habitat, even though craft is more
                # general and covers Ayse, but HRT is the familiar triple name and
                # the Hawking III says trans rights.
                "HRT phase θ",
                lambda state: common.format_num(
                    calc.phase_angle(
                        state.craft_entity(), state.reference_entity(),
                        state.target_entity()), "°") or "Same ref and targ",
                "Angle between Habitat, Reference, and Target",
                new_section=False))

        self._wtexts.append(
            TableText(
                "Throttle",
                lambda state: "{:.1%}".format(state.craft_entity().throttle),
                "Percentage of habitat's maximum rated engines",
                new_section=True))

        self._wtexts.append(
            TableText("Engine Acceleration",
                      lambda state: common.format_num(
                          calc.engine_acceleration(state), " m/s/s") +
                      (' [SRB]' if state.srb_time > 0 else ''),
                      "Acceleration due to craft's engine thrust",
                      new_section=False))

        self._wtexts.append(
            TableText("Drag",
                      lambda state: common.format_num(
                          calc.fastnorm(calc.drag(state)), " m/s/s"),
                      "Atmospheric drag acting on the craft",
                      new_section=False))

        self._wtexts.append(
            TableText("Fuel",
                      lambda state: common.format_num(
                          state.craft_entity().fuel, " kg"),
                      "Remaining fuel of craft",
                      new_section=False))

        def rotation_formatter(state: PhysicsState) -> str:
            deg_spin = round(np.degrees(state.craft_entity().spin), ndigits=1)
            if deg_spin < 0:
                return f"{-deg_spin} °/s cw"
            elif deg_spin > 0:
                return f"{deg_spin} °/s ccw"
            else:
                return f"{deg_spin} °/s"

        self._wtexts.append(
            TableText("Rotation",
                      rotation_formatter,
                      "Rotation speed of craft",
                      new_section=False))

        self._wtexts.append(
            TableText(
                "Ref altitude",
                lambda state: common.format_num(calc.altitude(
                    state.craft_entity(), state.reference_entity()) / 1000,
                                                " km",
                                                decimals=3),
                "Altitude of habitat above reference surface",
                new_section=True))

        self._wtexts.append(
            TableText("Ref speed",
                      lambda state: common.format_num(
                          calc.speed(state.craft_entity(),
                                     state.reference_entity()), " m/s"),
                      "Speed of habitat above reference surface",
                      new_section=False))

        self._wtexts.append(
            TableText(
                "Vertical speed",
                lambda state: common.format_num(
                    calc.v_speed(state.craft_entity(), state.reference_entity(
                    )), " m/s "),
                "Vertical speed of habitat towards/away reference surface",
                new_section=False))

        self._wtexts.append(
            TableText("Horizontal speed",
                      lambda state: common.format_num(
                          calc.h_speed(state.craft_entity(),
                                       state.reference_entity()), " m/s "),
                      "Horizontal speed of habitat across reference surface",
                      new_section=False))

        self._wtexts.append(
            TableText("Pitch θ",
                      lambda state: common.format_num(
                          np.degrees(
                              calc.pitch(state.craft_entity(
                              ), state.reference_entity())) % 360, "°"),
                      "Horizontal speed of habitat across reference surface",
                      new_section=False))

        self._wtexts.append(
            TableText("Targ altitude",
                      lambda state: common.format_num(calc.altitude(
                          state.craft_entity(), state.target_entity()) / 1000,
                                                      " km",
                                                      decimals=3),
                      "Altitude of habitat above reference surface",
                      new_section=True))

        self._wtexts.append(
            TableText("Targ speed",
                      lambda state: common.format_num(
                          calc.speed(state.craft_entity(), state.target_entity(
                          )), " m/s"),
                      "Speed of habitat above target surface",
                      new_section=False))

        self._wtexts.append(
            TableText(
                "Landing acc",
                lambda state: common.format_num(
                    calc.landing_acceleration(state.craft_entity(),
                                              state.target_entity()), " m/s/s"
                ) or "no vertical landing",
                "Constant engine acc to land during vertical descent to target",
                new_section=False))

        vpython.canvas.get_selected().caption += "</table>"
Beispiel #4
0
 def _label_text(self, entity: Entity, state: PhysicsState) -> str:
     label = super()._label_text(entity, state)
     label += '\nFuel: ' + common.format_num(entity.fuel, " kg")
     if entity.landed():
         label += '\nLanded'
     return label