def rotate_image(self, image_name, degrees, direction):

        input_image = cv2.imread(image_name, 1)

        file_name = "ReferenceImages/rotation.jpg"

        rotation = Rotation()

        if direction == "Clockwise":
            direction = "clockwise"
        else:
            direction = "counterclockwise"

        rotated_image = rotation.rotate(input_image, degrees, direction)

        cv2.imwrite(file_name, rotated_image)
        rows, cols = rotated_image.shape[0], rotated_image.shape[1]

        return file_name, rows, cols
Example #2
0
 def add_asteroid_belt(self, solar_system, asteroid_proto, n_asteroids,
                       orbit_radius_limits, orbit_time_limits):
     pix2 = 2 * math.pi
     for i in range(n_asteroids):
         asteroid_rotation = Rotation.generate(300, 5000)
         new_asteroid = asteroid_proto.clone(
             center=np.zeros(3),
             scale=self.generate_asteroid_size(),
             rot=asteroid_rotation)
         rot_angle = random.uniform(0, pix2)
         solar_system.add_satellite(
             satellite=new_asteroid,
             orbit_radius=random.uniform(orbit_radius_limits[0],
                                         orbit_radius_limits[1]),
             orbit_time=random.uniform(orbit_time_limits[0],
                                       orbit_time_limits[1]),
             init_orbit_angle=rot_angle)
Example #3
0
def rotate(body, vector, angle):
    from Rotation import Rotation
    return Rotation(body, vector, angle)
Example #4
0

def valmap(ivalue, istart, istop, ostart, ostop):
    """
    map a value from one input range to output range, like the Arduino map function
    :param ivalue: input value to map
    :param istart: input from
    :param istop: input to
    :param ostart: output from
    :param ostop:  output to
    :return: mapped input
    """
    return ostart + (ostop - ostart) * ((ivalue - istart) / (istop - istart))


rotation = Rotation()
seat = Seat()

lc = LedController()
lc.reset_leds()

erg = Erg()

videoControl = VideoControl()

optimal_dataframe = pickle.load(open("../analytics/goal_stroke", "rb"))

workout_start = time.time()
dist_per_time_needed = 6000 / 3600

last_seat_led = 0
Example #5
0
 def rotate(self):
     rotator = Rotation(self.filelist)
     rotator.rotate(90)
Example #6
0
# give access to all the funcitons in the rotation class

chloe = Camper("Chloe", 15, "Los Angeles", "sailing")
alec = Counselor("Alec", 19, "Bay Area", "Running")
annie = Counselor("Annie", 21, "Portland", "Musical theater")

# print(chloe.greeting())
# print(chloe.gets_cabin())
# print(chloe.gets_trip())

# print(alec.greeting()))
# print(alec.responsible_for_cabin())

# Need to call Rotation b/c it's an instance of Rotation class &
# how we get access to the activities we want to print.
rot = Rotation()
# call random rotation function and pass info to the camper
rand = rot.get_activities()
chloe.add_activity(rand)

print(alec.leads_evening_activities(rot))

# print(alec.responsible_for_cabin())

# twizzly_bop = Activity("twizzly bop", "10 am", "dock")

# print(chloe.activities)

# print(chloe.greeting())
# print(chloe.gets_trip())
# rot = Rotation()
Example #7
0
    def init_solar_system(self):
        self.background_painter = BackgroundPainter('images/space5.png')

        solar_rotation = Rotation(angle=0,
                                  axes=np.array([0., 0., 1.0]),
                                  time=5000)
        self.solar_system = System(
            master=Star(center=np.array([0., 0., 0.]),
                        radius=0.6,
                        img_name='images/globes/sun.jpg',
                        rot=solar_rotation))

        asteroid_rotation = Rotation(angle=29,
                                     axes=np.array([0., 1.0, 1.0]),
                                     time=200)
        self.asteroid_proto = ModelPrototype('models/asteroid/Asteroid.obj',
                                             center=np.array([0.0, 0.0, 0.0]),
                                             scale=np.array(
                                                 [0.001, 0.001, 0.001]),
                                             rot=asteroid_rotation)

        #self.solar_system.add_satellite(satellite=self.asteroid_proto, orbit_radius=0.7, orbit_time=400,
        #                                init_orbit_angle=1.9)

        mercury_rotation = Rotation(angle=7,
                                    axes=np.array([0., 0., 1.0]),
                                    time=10)
        mercury = Planet(center=np.zeros(3),
                         radius=0.05,
                         img_name='images/globes/mercury.jpg',
                         rot=mercury_rotation)
        self.solar_system.add_satellite(satellite=mercury,
                                        orbit_radius=0.7,
                                        orbit_time=400,
                                        init_orbit_angle=1.1)

        venus_rotation = Rotation(angle=3,
                                  axes=np.array([0., 0., 1.0]),
                                  time=3000)
        venus = Planet(center=np.zeros(3),
                       radius=0.06,
                       img_name='images/globes/venus.jpg',
                       rot=venus_rotation)
        self.solar_system.add_satellite(satellite=venus,
                                        orbit_radius=1.3,
                                        orbit_time=600,
                                        init_orbit_angle=0.5)

        earth_rotation = Rotation(angle=23,
                                  axes=np.array([0., 0., 1.0]),
                                  time=300)
        earth = Planet(center=np.zeros(3),
                       radius=0.06,
                       img_name='images/globes/earth.jpg',
                       rot=earth_rotation)
        earth_subsystem = System(earth)
        moon = Planet(center=np.zeros(3),
                      radius=0.01,
                      img_name='images/globes/moon.jpg')
        earth_subsystem.add_satellite(satellite=moon,
                                      orbit_radius=0.1,
                                      orbit_time=200)
        self.solar_system.append_subsystem(subsystem=earth_subsystem,
                                           orbit_radius=2.3,
                                           orbit_time=900,
                                           init_orbit_angle=2.3)

        mars_rotation = Rotation(angle=25,
                                 axes=np.array([0., 0., 1.0]),
                                 time=301)
        mars = Planet(center=np.zeros(3),
                      radius=0.04,
                      img_name='images/globes/mars.jpg',
                      rot=mars_rotation)
        self.solar_system.add_satellite(mars,
                                        orbit_radius=3.0,
                                        orbit_time=1200,
                                        init_orbit_angle=3.1)

        self.add_asteroid_belt(solar_system=self.solar_system,
                               asteroid_proto=self.asteroid_proto,
                               n_asteroids=self.n_asteroids,
                               orbit_radius_limits=(4.0, 5.0),
                               orbit_time_limits=(1000, 2000))

        ganimede = Planet(np.zeros(3), 0.03, 'images/globes/ganimede.jpg')
        upiter_rotation = Rotation(angle=3,
                                   axes=np.array([0., 0., 1.0]),
                                   time=200)
        upiter = Planet(np.zeros(3),
                        0.2,
                        'images/globes/upiter.jpg',
                        rot=upiter_rotation)
        upiter_subsystem = System(upiter)
        upiter_subsystem.add_satellite(satellite=ganimede,
                                       orbit_radius=0.3,
                                       orbit_time=200)
        self.solar_system.append_subsystem(subsystem=upiter_subsystem,
                                           orbit_radius=6.0,
                                           orbit_time=6000,
                                           init_orbit_angle=1.3)

        saturn_rotation = Rotation(angle=26,
                                   axes=np.array([0., 0., 1.0]),
                                   time=200)
        saturn_ring = Ring(center=np.zeros(3),
                           inner_radius=0.23,
                           outer_radius=0.4,
                           img_name='images/globes/saturn_ring2.png')
        saturn = RingedPlanet(center=np.zeros(3),
                              radius=0.19,
                              img_name='images/globes/saturn.jpg',
                              ring=saturn_ring,
                              rot=saturn_rotation)
        self.solar_system.add_satellite(satellite=saturn,
                                        orbit_radius=7.0,
                                        orbit_time=6500,
                                        init_orbit_angle=3.4)

        uranus_rotation = Rotation(angle=82,
                                   axes=np.array([0., 0., 1.0]),
                                   time=200)
        uranus_ring = Ring(center=np.zeros(3),
                           inner_radius=0.23,
                           outer_radius=0.4,
                           img_name='images/globes/uranus_ring.png')
        uranus = RingedPlanet(center=np.zeros(3),
                              radius=0.19,
                              img_name='images/globes/uranus.jpg',
                              ring=uranus_ring,
                              rot=uranus_rotation)
        self.solar_system.add_satellite(satellite=uranus,
                                        orbit_radius=8.2,
                                        orbit_time=8000,
                                        init_orbit_angle=2.624)

        neptune_rotation = Rotation(angle=29,
                                    axes=np.array([0., 0., 1.0]),
                                    time=200)
        neptune = Planet(center=np.zeros(3),
                         radius=0.19,
                         img_name='images/globes/neptune.jpg',
                         rot=neptune_rotation)
        self.solar_system.add_satellite(satellite=neptune,
                                        orbit_radius=12.2,
                                        orbit_time=10000,
                                        init_orbit_angle=1.8)

        # self.x_wing = ModelPrototype('models/TIEFIGHTER/TF_3DS02.3ds', center=np.array([0.7, 0.7, 0.7]),
        #                                      scale=np.array([0.01, 0.01, 0.01]))
        # self.destroyer = ModelPrototype('models/star wars star destroyer/star wars star destroyer.3ds', center=np.array([1.4, 1.4, 1.4]),
        #                                                                scale=np.array([0.01, 0.01, 0.01]))

        self.falcon = ModelPrototype(
            'models/star_wars_falcon/star_wars_falcon.3ds',
            center=np.array([0.0, 0.0, 0.0]),
            scale=np.array([0.001, 0.001, 0.001]))