Exemple #1
0
    def angle_cw_degs(self):
        """CW angle in degrees"""
        m = self.modulo
        if m == 0:
            return degrees(0)

        a = math.acos(self.y / m) * 180 / math.pi
        if self.x >= 0:
            return degrees(360 - a)
        return degrees(a)
Exemple #2
0
    def angle_cw_degs(self):
        """CW angle in degrees"""
        m = self.modulo
        if m == 0:
            return degrees(0)

        a = math.acos(self.y / m) * 180 / math.pi
        if self.x >= 0:
            return degrees(360 - a)
        return degrees(a)
Exemple #3
0
 def fire_thruster(self):
     """Fire thruster"""
     self.propellent -= 10
     thrust = GVector(.1, 0)
     thrust.angle_cw_degs = degrees(180) - self._angle
     self.gspeed += thrust
     self._start_orbit_prediction()
     t = Thruster(self.gcenter, thrust)
     game._particles.append(t)
 def __init__(self, ship, n, light_angle):
     gloss.Sprite.__init__(self, gloss.Texture('art/shuttle_light_%s.png' % n))
     self._ship = ship
     self.gspeed = ship.gspeed
     self.gcenter = ship.gcenter
     self.mass = 4
     self._raw_scale = .015 # fixme
     self._alpha = 0
     self._light_angle = degrees(light_angle)
Exemple #5
0
 def __init__(self, gcenter):
     gloss.Sprite.__init__(self, gloss.Texture('art/shuttle.png'))
     self._angle = degrees(0)
     self._target_angle = degrees(0)
     self._angular_velocity = degrees_per_sec(0)
     self._orbit_prediction_thread = None
     self._orbit_prediction_running = False
     self._raw_scale = .025
     self._raw_scale = .015  # fixme
     self._tp = None
     self.gcenter = gcenter
     self.gspeed = GVector(0, -0.3)
     self.mass = 4
     self.orbit = ()
     self.propellent = 1500
     self.hull_temperature = 0
     self.landing_gears_deployed = False
     self._start_orbit_prediction()
 def fire_thruster(self):
     """Fire thruster"""
     self.propellent -= 10
     thrust = GVector(.1, 0)
     thrust.angle_cw_degs = degrees(180) - self._angle
     self.gspeed += thrust
     self._start_orbit_prediction()
     t = Thruster(self.gcenter, thrust)
     game._particles.append(t)
 def __init__(self, gcenter):
     gloss.Sprite.__init__(self, gloss.Texture('art/shuttle.png'))
     self._angle = degrees(0)
     self._target_angle = degrees(0)
     self._angular_velocity = degrees_per_sec(0)
     self._orbit_prediction_thread = None
     self._orbit_prediction_running = False
     self._raw_scale = .025
     self._raw_scale = .015 # fixme
     self._tp = None
     self.gcenter = gcenter
     self.gspeed = GVector(0, -0.3)
     self.mass = 4
     self.orbit = ()
     self.propellent = 1500
     self.hull_temperature = 0
     self.landing_gears_deployed = False
     self._start_orbit_prediction()
Exemple #8
0
 def __init__(self, ship, n, light_angle):
     gloss.Sprite.__init__(self,
                           gloss.Texture('art/shuttle_light_%s.png' % n))
     self._ship = ship
     self.gspeed = ship.gspeed
     self.gcenter = ship.gcenter
     self.mass = 4
     self._raw_scale = .015  # fixme
     self._alpha = 0
     self._light_angle = degrees(light_angle)
Exemple #9
0
    def destination(self, point, bearing, distance=None):
        point = Point(point)
        lat1 = units.radians(degrees=point.latitude)
        lng1 = units.radians(degrees=point.longitude)
        bearing = units.radians(degrees=bearing)

        if distance is None:
            distance = self
        if isinstance(distance, Distance):
            distance = distance.kilometers

        d_div_r = float(distance) / self.RADIUS

        lat2 = asin(
            sin(lat1) * cos(d_div_r) +
            cos(lat1) * sin(d_div_r) * cos(bearing)
        )

        lng2 = lng1 + atan2(
            sin(bearing) * sin(d_div_r) * cos(lat1),
            cos(d_div_r) - sin(lat1) * sin(lat2)
        )

        return Point(units.degrees(radians=lat2), units.degrees(radians=lng2))
Exemple #10
0
    def parse_degrees(cls, degrees, arcminutes, arcseconds, direction=None):
        negative = degrees < 0 or degrees.startswith('-')
        degrees = float(degrees or 0)
        arcminutes = float(arcminutes or 0)
        arcseconds = float(arcseconds or 0)

        if arcminutes or arcseconds:
            more = units.degrees(arcminutes=arcminutes, arcseconds=arcseconds)
            if negative:
                degrees -= more
            else:
                degrees += more

        if direction in [None, 'N', 'E']:
            return degrees
        elif direction in ['S', 'W']:
            return -degrees
        else:
            raise ValueError("Invalid direction! Should be one of [NSEW].")
Exemple #11
0
    def parse_degrees(cls, degrees, arcminutes, arcseconds, direction=None):
        negative = degrees < 0 or degrees.startswith('-')
        degrees = float(degrees or 0)
        arcminutes = float(arcminutes or 0)
        arcseconds = float(arcseconds or 0)

        if arcminutes or arcseconds:
            more = units.degrees(arcminutes=arcminutes, arcseconds=arcseconds)
            if negative:
                degrees -= more
            else:
                degrees += more

        if direction in [None, 'N', 'E']:
            return degrees
        elif direction in ['S', 'W']:
            return -degrees
        else:
            raise ValueError("Invalid direction! Should be one of [NSEW].")
Exemple #12
0
    def __init__(self, gcenter, thrust):
        self.gcenter = gcenter
        tex = gloss.Texture("smoke.tga")

        wind = PVector(game.zoom * 48, 0)
        wind.angle_cw_degs = degrees(180) - thrust.angle_cw_degs
        wind = wind.round_tup

        self._ps = gloss.ParticleSystem(
            tex,
            onfinish=self._finished,
            position=gcenter.on_screen.tup,
            name="smoke",
            initialparticles=20,
            particlelifespan=190,
            growth=.8,
            wind=wind,
            minspeed=.1,
            maxspeed=10,
            minscale=game.zoom * .05,
            maxscale=game.zoom * .1,
            startcolor=Color(1, 1, 1, 1),
            endcolor=Color(1, 1, 1, 0),
        )
    def __init__(self, gcenter, thrust):
        self.gcenter = gcenter
        tex = gloss.Texture("smoke.tga")

        wind = PVector(game.zoom * 48, 0)
        wind.angle_cw_degs = degrees(180) - thrust.angle_cw_degs
        wind = wind.round_tup

        self._ps = gloss.ParticleSystem(
            tex,
            onfinish = self._finished,
            position = gcenter.on_screen.tup,
            name = "smoke",
            initialparticles = 20,
            particlelifespan = 190,
            growth = .8,
            wind = wind,
            minspeed = .1,
            maxspeed = 10,
            minscale = game.zoom * .05,
            maxscale = game.zoom * .1,
            startcolor = Color(1, 1, 1, 1),
            endcolor = Color(1, 1, 1, 0),
        )
    def __init__(self, ship, cw=True):
        self.gcenter = ship.gcenter
        self._tex = gloss.Texture("smoke.tga")
        self._ps = [] # Running particle systems

        # Distance of the RCS thrusters from the ship center
        gdelta_front = GVector(3.5, 0)
        gdelta_front.angle_cw_degs = degrees(180) - ship._angle
        gdelta_rear = GVector(4, 0)
        gdelta_rear.angle_cw_degs = degrees(0) - ship._angle

        wind_front = PVector(100, 0)
        wind_rear = PVector(200, 0)

        if cw:
            wind_front.angle_cw_degs = degrees(270) - ship._angle
            wind_rear.angle_cw_degs = degrees(90) - ship._angle
        else:
            wind_front.angle_cw_degs = degrees(90) - ship._angle
            wind_rear.angle_cw_degs = degrees(270) - ship._angle

        self._create_particles(ship.gcenter + gdelta_front, wind_front)
        self._create_particles(ship.gcenter + gdelta_rear, wind_rear)
Exemple #15
0
    def __init__(self, ship, cw=True):
        self.gcenter = ship.gcenter
        self._tex = gloss.Texture("smoke.tga")
        self._ps = []  # Running particle systems

        # Distance of the RCS thrusters from the ship center
        gdelta_front = GVector(3.5, 0)
        gdelta_front.angle_cw_degs = degrees(180) - ship._angle
        gdelta_rear = GVector(4, 0)
        gdelta_rear.angle_cw_degs = degrees(0) - ship._angle

        wind_front = PVector(100, 0)
        wind_rear = PVector(200, 0)

        if cw:
            wind_front.angle_cw_degs = degrees(270) - ship._angle
            wind_rear.angle_cw_degs = degrees(90) - ship._angle
        else:
            wind_front.angle_cw_degs = degrees(90) - ship._angle
            wind_rear.angle_cw_degs = degrees(270) - ship._angle

        self._create_particles(ship.gcenter + gdelta_front, wind_front)
        self._create_particles(ship.gcenter + gdelta_rear, wind_rear)
Exemple #16
0
 def makeMoveToOtherSideOfObstacles(self, ent):
     ent.yaw = degrees(90)
     desiredState = StoppedAtPosition(vector3(0, 0, -2000))
     cmd = command.MoveTo(self.engine, desiredState)
     ent.squad.SquadAI.commands = [cmd]
Exemple #17
0
    def destination(self, point, bearing, distance=None):
        point = Point(point)
        lat1 = units.radians(degrees=point.latitude)
        lng1 = units.radians(degrees=point.longitude)
        bearing = units.radians(degrees=bearing)

        if distance is None:
            distance = self
        if isinstance(distance, Distance):
            distance = distance.kilometers

        ellipsoid = self.ELLIPSOID
        if isinstance(ellipsoid, basestring):
            ellipsoid = ELLIPSOIDS[ellipsoid]

        major, minor, f = ellipsoid

        tan_reduced1 = (1 - f) * tan(lat1)
        cos_reduced1 = 1 / sqrt(1 + tan_reduced1 ** 2)
        sin_reduced1 = tan_reduced1 * cos_reduced1
        sin_bearing, cos_bearing = sin(bearing), cos(bearing)
        sigma1 = atan2(tan_reduced1, cos_bearing)
        sin_alpha = cos_reduced1 * sin_bearing
        cos_sq_alpha = 1 - sin_alpha ** 2
        u_sq = cos_sq_alpha * (major ** 2 - minor ** 2) / minor ** 2

        A = 1 + u_sq / 16384. * (
            4096 + u_sq * (-768 + u_sq * (320 - 175 * u_sq))
        )
        B = u_sq / 1024. * (256 + u_sq * (-128 + u_sq * (74 - 47 * u_sq)))

        sigma = distance / (minor * A)
        sigma_prime = 2 * pi

        while abs(sigma - sigma_prime) > 10e-12:
            cos2_sigma_m = cos(2 * sigma1 + sigma)
            sin_sigma, cos_sigma = sin(sigma), cos(sigma)
            delta_sigma = B * sin_sigma * (
                cos2_sigma_m + B / 4. * (
                    cos_sigma * (
                        -1 + 2 * cos2_sigma_m
                    ) - B / 6. * cos2_sigma_m * (
                        -3 + 4 * sin_sigma ** 2) * (
                        -3 + 4 * cos2_sigma_m ** 2
                    )
                )
            )
            sigma_prime = sigma
            sigma = distance / (minor * A) + delta_sigma

        sin_sigma, cos_sigma = sin(sigma), cos(sigma)

        lat2 = atan2(
            sin_reduced1 * cos_sigma + cos_reduced1 * sin_sigma * cos_bearing,
            (1 - f) * sqrt(
                sin_alpha ** 2 + (
                    sin_reduced1 * sin_sigma -
                    cos_reduced1 * cos_sigma * cos_bearing
                ) ** 2
            )
        )

        lambda_lng = atan2(
            sin_sigma * sin_bearing,
            cos_reduced1 * cos_sigma - sin_reduced1 * sin_sigma * cos_bearing
        )

        C = f / 16. * cos_sq_alpha * (4 + f * (4 - 3 * cos_sq_alpha))

        delta_lng = (
            lambda_lng - (1 - C) * f * sin_alpha * (
                sigma + C * sin_sigma * (
                    cos2_sigma_m + C * cos_sigma * (
                        -1 + 2 * cos2_sigma_m ** 2
                    )
                )
            )
        )

        final_bearing = atan2(
            sin_alpha,
            cos_reduced1 * cos_sigma * cos_bearing - sin_reduced1 * sin_sigma
        )

        lng2 = lng1 + delta_lng

        return Point(units.degrees(radians=lat2), units.degrees(radians=lng2))