Exemplo n.º 1
0
    def from_state_vectors(cls,
                           pos: TypeVar_NumPy3DArray,
                           vel: TypeVar_NumPy3DArray,
                           epoch: TypeVar_DateTime,
                           name="UNNAMED SATELLITE") -> object:
        """
        Creates an instance of Orbit object, using both position and velocity vectors at given epoch

        :param pos: vector of position, in GCRS rect frame, at given epoch. units: ([m], [m], [m])
        :param vel: vector of velocity, in GCRS rect frame, at given epoch. units: ([m/s], [m/s], [m/s])
        :param epoch: corresponding epoch
        :type pos: NumPy 3D array
        :type vel: NumPy 3D array
        :type epoch: Arrow object
        :returns: Orbit object
        """
        x = np.array([1, 0, 0])
        z = np.array([0, 0, 1])

        kinetic = np.cross(pos, vel)
        kinetic_sq = kinetic.dot(kinetic)
        pos_dir = Maths.normalize_vect(pos)
        ecc_vec = np.cross(vel, kinetic) / Orbit.MU_EARTH - pos_dir
        minusy_ellipse = np.cross(kinetic, ecc_vec) * (-1)

        e = np.linalg.norm(ecc_vec)  # [1]
        ee = e * e
        eee = ee * e
        eeee = eee * e
        i = Maths.angle_vects(z, kinetic)  # [rad]
        nu = Maths.angle_vects(pos_dir, ecc_vec)
        raan = Maths.angle_vects(x, minusy_ellipse)  # [rad]
        argp = Maths.angle_vects(minusy_ellipse, ecc_vec)  # [rad]
        a = kinetic_sq / Orbit.MU_EARTH / (1 - e * e)
        aaa = a * a * a
        n = np.sqrt(Orbit.MU_EARTH / aaa)  # [rad/s]
        M = (nu - 2 * e * np.sin(nu) +
             (3 / 4 * ee + 1 / 8 * eeee) * np.sin(2 * nu) -
             1 / 3 * eee * np.sin(3 * nu) + 5 / 32 * eeee * np.sin(4 * nu))

        return cls(epoch, e, np.rad2deg(i), np.rad2deg(raan), np.rad2deg(argp),
                   n * 86400 / Maths.TWOPI, np.rad2deg(M), "idk")
Exemplo n.º 2
0
    def bbq_check(self, rot_list: list, safe_angle: float):
        """
            check for bbq
            :param rot_list: list of rotations generated with 'rot_qsw'
            :param safe_angle: safe angle for bbq [rad]
        """
        bbq_alert = []

        for rot in rot_list:
            x = rot["gcrs_start_dir"]
            y = rot["gcrs_target_dir"]
            z = np.cross(x, y)

            t = arrow.get(rot["unix_start"])
            ts = self.simulation.get_closest_timestamp(t)
            s = ts["sun_pos_gcrs"]
            s = Maths.normalize_vect(s)

            alert = False

            angle_norm_plane = Maths.angle_vects(z, s)

            if angle_norm_plane > Maths.HALFPI - safe_angle:
                if Maths.angle_vects(x, s) < safe_angle or Maths.angle_vects(
                        y, s) < safe_angle:
                    alert = True
                else:
                    a = np.cross(z, x)
                    b = np.cross(y, z)
                    if np.dot(s, a) > 0 and np.dot(s, b) > 0:
                        alert = True

            if alert:
                bbq_alert.append(rot)

        return bbq_alert if len(bbq_alert) != 0 else True