Exemple #1
0
    def test_earth_moon_loop(self):
        """Test that moon loops over Earth."""
        moon = dot.Dot()
        moon.mass = constants.MOON.MASS
        moon.pos[0] = constants.MOON.PERIGEE_ORBIT_RADIUS
        init_moon_pos = numpy.array(moon.pos)
        moon.vel[1] = constants.MOON.MAX_ORBITAL_VELOCITY

        earth = dot.Dot()
        earth.mass = constants.EARTH.MASS
        # Set system inertion to 0
        earth.vel[
            1] = -constants.MOON.MAX_ORBITAL_VELOCITY * moon.mass / earth.mass

        test_space = space.Space(dots=[earth, moon])

        # Distance between moon initial position and position after loop
        min_distance = numpy.inf

        n_loops = 4.
        n_iterations = 10000
        t = 0
        dt = n_loops * constants.MOON.SIDEREAL_ROTATION_PERIOD / n_iterations
        for iteration in range(n_iterations):
            test_space.step(time=dt)
            t += dt
            if t > constants.MOON.SIDEREAL_ROTATION_PERIOD / 2:
                min_distance = min(
                    min_distance,
                    space.Space.distance(init_moon_pos, moon.pos),
                )

        assert min_distance < constants.MOON.RADIUS / 100, "Moon not reached init position."
Exemple #2
0
 def test_roof_and_floor(self):
     left_pillar = [dot.Dot([2, 2]), dot.Dot([3, 2])]
     right_pillar = [dot.Dot([2, 3]), dot.Dot([3, 3])]
     roof, floor = self.mygrid.roof_and_floor(left_pillar, right_pillar)
     self.assertEqual(roof[0], left_pillar[0])
     self.assertEqual(roof[1], right_pillar[0])
     self.assertEqual(floor[0], left_pillar[1])
     self.assertEqual(floor[0], left_pillar[1])
Exemple #3
0
 def test_pillar_lines(self):
     roof = [dot.Dot([1, 2]), dot.Dot([1, 3])]
     floor = [dot.Dot([2, 2]), dot.Dot([2, 3])]
     left_pillar, right_pillar = self.mygrid.pillar_lines(roof, floor)
     self.assertEqual(roof[0], left_pillar[0])
     self.assertEqual(roof[1], right_pillar[0])
     self.assertEqual(floor[0], left_pillar[1])
     self.assertEqual(floor[0], left_pillar[1])
Exemple #4
0
    def test_simple_earth_gravity(self):
        """Test gravitational acceleration at Earth surface near 9.8 m/s^2."""
        earth = dot.Dot()
        earth.mass = constants.EARTH.MASS

        simple_dot = dot.Dot()
        simple_dot.pos[0] = constants.EARTH.RADIUS

        test_space = space.Space(dots=[earth, simple_dot])

        test_space.step_acceleration()
        assert math.isclose(simple_dot.acc[0], -9.8, abs_tol=0.01)
Exemple #5
0
 def __init__(self, starting_pos, goal_pos, gen_size=50, movement_size=1, num_survivors=10):
     self.size = gen_size
     self.movement_size = movement_size
     self.dots = []
     self.starting_pos = starting_pos.copy()
     self.goal_pos = goal_pos.copy()
     self.x_move_stats = []
     self.y_move_stats = []
     self.best_num = num_survivors
     self.prev_bests = []
     for i in range(self.best_num):
         self.prev_bests.append(Dot.Dot(x_pos=starting_pos[0], y_pos=starting_pos[1]))
     for i in range(gen_size):
         self.dots.append(Dot.Dot(starting_pos[0], starting_pos[1]))
Exemple #6
0
 def test_is_horizontal(self):
     self.assertFalse(
         self.mygrid.is_horizontal([dot.Dot([0, 0]),
                                    dot.Dot([1, 0])]))
     self.assertTrue(
         self.mygrid.is_horizontal([dot.Dot([0, 0]),
                                    dot.Dot([0, 1])]))
     self.assertTrue(
         self.mygrid.is_horizontal([dot.Dot([3, 2]),
                                    dot.Dot([3, 3])]))
     self.assertFalse(
         self.mygrid.is_horizontal([dot.Dot([3, 3]),
                                    dot.Dot([2, 3])]))
     self.assertTrue(
         self.mygrid.is_horizontal([dot.Dot([2, 2]),
                                    dot.Dot([2, 1])]))
Exemple #7
0
 def test_dot_below(self):
     self.assertEqual(self.mygrid.dot_below(dot.Dot([0, 1])),
                      dot.Dot([1, 1]))
     self.assertIsNone(self.mygrid.dot_below(dot.Dot([3, 3])))
     self.assertEqual(self.mygrid.dot_below(dot.Dot([2, 2])),
                      dot.Dot([3, 2]))
     self.assertEqual(self.mygrid.dot_below(dot.Dot([1, 3])),
                      dot.Dot([2, 3]))
     self.assertIsNone(self.mygrid.dot_below(dot.Dot([3, 0])))
Exemple #8
0
 def test_dot_above(self):
     self.assertEqual(self.mygrid.dot_above(dot.Dot([1, 1])),
                      dot.Dot([0, 1]))
     self.assertIsNone(self.mygrid.dot_above(dot.Dot([0, 3])))
     self.assertEqual(self.mygrid.dot_above(dot.Dot([3, 0])),
                      dot.Dot([2, 0]))
     self.assertEqual(self.mygrid.dot_above(dot.Dot([2, 2])),
                      dot.Dot([1, 2]))
     self.assertIsNone(self.mygrid.dot_above(dot.Dot([0, 0])))
Exemple #9
0
 def test_dot_to_left_of(self):
     self.assertEqual(self.mygrid.dot_to_left_of(dot.Dot([0, 1])),
                      dot.Dot([0, 0]))
     self.assertIsNone(self.mygrid.dot_to_left_of(dot.Dot([0, 0])))
     self.assertEqual(self.mygrid.dot_to_left_of(dot.Dot([2, 2])),
                      dot.Dot([2, 1]))
     self.assertEqual(self.mygrid.dot_to_left_of(dot.Dot([3, 1])),
                      dot.Dot([3, 0]))
     self.assertIsNone(self.mygrid.dot_to_left_of(dot.Dot([3, 0])))
Exemple #10
0
 def test_dot_to_right_of(self):
     self.assertEqual(self.mygrid.dot_to_right_of(dot.Dot([0, 1])),
                      dot.Dot([0, 2]))
     self.assertIsNone(self.mygrid.dot_to_right_of(dot.Dot([0, 3])))
     self.assertEqual(self.mygrid.dot_to_right_of(dot.Dot([3, 2])),
                      dot.Dot([3, 3]))
     self.assertEqual(self.mygrid.dot_to_right_of(dot.Dot([0, 0])),
                      dot.Dot([0, 1]))
     self.assertIsNone(self.mygrid.dot_to_right_of(dot.Dot([3, 3])))
Exemple #11
0
 def test_not_adjacent(self):
     self.assertFalse(
         self.mygrid.not_adjacent(dot.Dot([1, 2]), dot.Dot([2, 2])))
     self.assertTrue(
         self.mygrid.not_adjacent(dot.Dot([2, 2]), dot.Dot([2, 2])))
     self.assertFalse(
         self.mygrid.not_adjacent(dot.Dot([2, 1]), dot.Dot([3, 1])))
     self.assertTrue(
         self.mygrid.not_adjacent(dot.Dot([1, 1]), dot.Dot([2, 2])))
Exemple #12
0
 def __init__(self, x1, y1, w):
     print "ALine.__init__"
     self._x = x1
     self._y = y1
     self._w = w
     self._controls = {}
     self._dot = dot.Dot(self._x, self._y, 0)
     self._num_triangles = 100
Exemple #13
0
def drawCurvyArrow(ctx, startPos, endPos, middlePos, cust):
    if type(cust) is DictType: cust = dot.Dot(cust)
    if not middlePos:
        middlePos = [((startPos[0] + endPos[0]) / 2,
                      (startPos[1] + endPos[1]) / 2)]
    ctx.save()
    ctx.set_source_rgba(*cust.color)
    ctx.set_line_width(cust.lineThickness)

    # We don't want the curvy arrow's line to lay over the beginning button
    buttonRadius = cust.get("buttonRadius", 4)
    if buttonRadius:  # so go a few pixels in the correct direction
        lv = lineVector(startPos, middlePos[0])
        sp = (startPos[0] + lv[0] * (buttonRadius - .05),
              startPos[1] + lv[1] * (buttonRadius - .05))
    else:
        sp = startPos

    # Calculate the arrow at the end of the line
    (a, b) = calcArrow(middlePos[0][0], middlePos[0][1], endPos[0], endPos[1],
                       cust.arrowLength, cust.arrowAngle)

    # We don't want the line to overlap the arrow at the end of it, so
    # calculate a new endpoint for the line by finding the midpoint of the back of the arrow
    ep = ((a[0] + b[0]) / 2, (a[1] + b[1]) / 2)

    ctx.move_to(*sp)
    try:
        ctx.curve_to(middlePos[0][0], middlePos[0][1], middlePos[0][0],
                     middlePos[0][1], ep[0], ep[1])
    except:
        pdb.set_trace()

    ctx.stroke()

    ctx.set_line_width(
        .1
    )  # These will be filled, so set the containing line width to be invisibly thin

    if buttonRadius:
        ctx.arc(startPos[0], startPos[1], cust.buttonRadius, 0,
                2 * 3.141592637)
        ctx.close_path()
        ctx.stroke_preserve()
        ctx.set_source_rgba(cust.color[0], cust.color[1], cust.color[2],
                            cust.color[3])
        ctx.fill()

    # Draw the arrow on the end
    ctx.set_source_rgba(*cust.color)
    ctx.move_to(endPos[0], endPos[1])
    ctx.line_to(*a)
    ctx.line_to(*b)
    ctx.close_path()
    ctx.stroke_preserve()
    ctx.fill()
    ctx.restore()
Exemple #14
0
def generate_dot(dotgroup, window_size, config):
    ek = lambda p: dotgroup[p] if p in dotgroup else (
        ep(dotgroup['template'][p], config)
        if p in dotgroup['template'] else None)
    args = {
        i: ek(i)
        for i in
        ['loc', 'radius', 'color', 'period', 'phase', 'duty', 'motile']
        if ek(i) != None
    }
    args['window_size'] = window_size
    args['loc'] = [ep(i, config) for i in args['loc']]
    return dot.Dot(**args)
Exemple #15
0
 def __init__(self, gameWorld, startpos, size):
     """
     Creat a bunch of dots.
     """
     self.dots = []
     self.gworld = gameWorld
     self.startpos = startpos
     self.size = size
     self.fitnesssum = 0
     self.generation = 1
     self.bestdot = 0
     self.maxsteps = 400
     for _ in range(size):
         self.dots.append(dot.Dot(self.gworld, self.startpos))
def TestCreate(name):
  """Internal module unit test"""
  import aspAmfCreate
  import dot
  s = Session()
  n = s.GetRunningAmfNodes()
  ent = aspAmfCreate.CreateApp(name,n,dot.Dot({"rModel":"2N"}),[{"key":"value"}])
  s.InstallEntities(ent)
  s.InstallCsiConfig(ent)
  s.InstallCompConfig(ent)
  s.InstallNodeConfig(ent)
  s.InstallSgConfig(ent)
  s.InstallSiConfig(ent)
  s.InstallSuConfig(ent)
  s.Startup((ServiceGroupType,name + "SGi0"))
  s.Startup((ServiceUnitType,name + "SUi0_1"))
Exemple #17
0
    def __init__(self,
                 color=(0, 0, 0, .9),
                 circleRadius=5,
                 linethickness=4,
                 arrowlen=15,
                 arrowangle=PI / 8):
        Gesture.__init__(self)
        wx.Timer.__init__(self)
        self.cust = dot.Dot()

        self.cust.color = color
        self.cust.buttonRadius = circleRadius
        self.cust.lineThickness = linethickness
        self.cust.arrowLength = arrowlen
        self.cust.arrowAngle = arrowangle

        self.downPos = self.curPos = None
        self.center = None

        self.frameInterval = 10  # Targeted milliseconds between frame redraws
        self.frameAverage = self.frameInterval  # Actual (measured) milliseconds between redraws
        self.lastFrame = None  # When the last Notify occurred

        self.settleTime = 250.0  # How long in milliseconds should the line take to straighten
Exemple #18
0
 def test_update_list_of_drawn_lines_with(self):
     self.mygame.list_of_lines_drawn = [[dot.Dot([0, 0]),
                                         dot.Dot([0, 1])],
                                        [dot.Dot([0, 2]),
                                         dot.Dot([0, 3])],
                                        [dot.Dot([2, 2]),
                                         dot.Dot([3, 2])],
                                        [dot.Dot([1, 2]),
                                         dot.Dot([1, 3])]]
     self.mygame.update_list_of_drawn_lines_with(
         [dot.Dot([2, 0]), dot.Dot([1, 0])])
     self.assertNotIn([dot.Dot([2, 0]), dot.Dot([1, 0])],
                      self.mygame.list_of_lines_drawn)
     self.assertIn([dot.Dot([1, 0]), dot.Dot([2, 0])],
                   self.mygame.list_of_lines_drawn)
     self.mygame.update_list_of_drawn_lines_with(
         [dot.Dot([2, 3]), dot.Dot([2, 2])])
     self.assertNotIn([dot.Dot([2, 3]), dot.Dot([2, 2])],
                      self.mygame.list_of_lines_drawn)
     self.assertIn([dot.Dot([2, 2]), dot.Dot([2, 3])],
                   self.mygame.list_of_lines_drawn)
Exemple #19
0
 def test_is_rightmost(self):
     self.assertFalse(self.mygrid.is_rightmost(dot.Dot([1, 1])))
     self.assertFalse(self.mygrid.is_rightmost(dot.Dot([0, 0])))
     self.assertTrue(self.mygrid.is_rightmost(dot.Dot([3, 3])))
     self.assertTrue(self.mygrid.is_rightmost(dot.Dot([2, 3])))
     self.assertTrue(self.mygrid.is_rightmost(dot.Dot([0, 3])))
Exemple #20
0
def init(data, doorMap):
    data.bg = background.Background(goodBLUE)
    data.boundary = outerWall.OuterWall(WHITE)
    data.walls = allWalls.AllWalls(doorMap, WHITE)
    data.dot = dot.Dot(60, 60, doorMap)
    start_end.start(data.dot)
Exemple #21
0
def main(isToCut):
    title_window = ''

    def on_trackbar(val):
        alpha = val / alpha_slider_max
        beta = (1.0 - alpha)
        dst = cv2.addWeighted(src1, alpha, src2, beta, 0.0)
        cv2.imshow(title_window, dst)

    def nothing(x):
        pass


    #Argumentos do método 'face_cascade.detectMultiScale'(OBS.: está bom para uma curta distância)
#    scaleFactor = 1.06
 #   minNeighbors = 50
    scaleFactor = 1.3
    minNeighbors = 5

    name = "Hey dboa man?"
    #name1 = "ihoi"
    #folder = "new_imgs"
    #bar = ["right eye:", "left eye:"]
    bar_name = "value of trackbar eye:"
    #count = 0
    cam = cv2.VideoCapture(0)
    cam.set(cv2.CAP_PROP_FPS, 30)

    limite = 0

    #importa o classificador de face
    face_cascade = cv2.CascadeClassifier('haarcascades/haarcascade_frontalface_default.xml')
    #importa o classificador de olho
    eye_cascade = cv2.CascadeClassifier('haarcascades/haarcascade_eye.xml')

    #Iniciando o algoritmo Blob
    blob_parm = cv2.SimpleBlobDetector_Params()
    blob_parm.filterByArea = True
    blob_parm.maxArea = 1500 #unidade em pixels
    blob_dt = cv2.SimpleBlobDetector_create(blob_parm)

    #Desenha as barras deslizantes na janela

    cv2.namedWindow(name)
    cv2.createTrackbar(bar_name, name, 0, 255, nothing)

    #Criando o ponto

    obj = dot.Dot()

    while(True):
        ret, frame = cam.read()
        #'''
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        
        #aplica o algoritmo de detecção facial
        faces = face_cascade.detectMultiScale(gray, scaleFactor, minNeighbors)
                
        #Direito
        
        #Esquerdo
        #cv2.createTrackbar(bar[1], name, 0, 255, nothing)

        if cv2.waitKey(1) == ord('o'):
            for i in range(10):
                obj.move_dot()
         #letra 'q'
        if cv2.waitKey(1) == ord('q'):
            obj.exit_window()
            break

        for (x,y,w,h) in faces:
    
            cv2.rectangle(frame,(x,y),(x+w,y+h),(255,0,0),2)
            roi_gray = gray[y:y+h, x:x+w]
            roi_color = frame[y:y+h, x:x+w]

            cv2.GaussianBlur(roi_gray, (3, 3), 0.005 * (w*h))

            #aplica o algoritmo de detecção do olho
            eyes = eye_cascade.detectMultiScale(roi_gray)
            for i in range(len(eyes)):    
                (ex,ey,ew,eh) = eyes[i]
                if ey < 1/2*(y+h) - 100:
                    cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2)   
                    try:
                        limite = cv2.getTrackbarPos(bar_name, name) 
                    except IndexError:
                        print("Há mais de um elemento na cena que está atrapalhando a detecção do usuário. Try Again Pls :)")

                    eye_img = roi_color[ey:ey+eh, ex:ex+ew]
                    if isToCut:
                        eye_img = ce.cut_eyebrows(eye_img)
                    #cutImg.salveSubImg(0, 0, np.size(eye_img, 1), np.size(eye_img, 0), eye_img, count, folder)
                    keypoints = blob.blob_process(eye_img, blob_dt, limite)
                    cv2.drawKeypoints(eye_img, keypoints, eye_img, (0, 0, 255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
                    cv2.imshow("asdf",blob.img_blob_process(eye_img, blob_dt, limite, 1))
                    #cutImg.salveSubImg(ex, ey, ew, eh, roi_color, count)
                    #count+=1


                    #PROBLEMAS AQUI v 
                    for i in keypoints:   
                        if 30 > i.pt[0]:
                            print("left?")
                        else:
                            print("right?")
                        print(i.pt[0], end=' ')
                        print(i.pt[1])
                    
        #print(cv2.getTrackbarPos(bar_name, name) )
        #cv2.imshow(name1, u)
        cv2.imshow(name, frame)
        #print(cam.get(cv2.CAP_PROP_FPS))
    
    cam.release()
    cv2.destroyWindow(name) 
Exemple #22
0
 def make_first_pop(self):
     for i in range(self.pop_size):
         # dots are always added to the population and canvas, never removed
         self.population.append(dot.Dot(self.canvas, self.brain_size))
Exemple #23
0
# https://www.soundjay.com/beep-sounds-1.html


# Import and initialize the pygame library
import pygame
import dot

# Set up the drawing window
#pygame.mixer.pre_init(44100,16,2,4096)
pygame.init()
screen = pygame.display.set_mode([600, 600])
timer  = pygame.time.Clock()
#effect = pygame.mixer.Sound('vinyl.wav')  # set up the sound clip

# create a dot object
d1 = dot.Dot((255,500), (250,0))
d2 = dot.Dot((0,250), (500,250))

dots=[d1,d2]
sprites = pygame.sprite.Group()
sprites.add(d1)
sprites.add(d2)

# Fill the background with white
screen.fill((255, 255, 255))

#Run until the user asks to quit
running = True
while running:

    # Did the user click the window close button?
Exemple #24
0
    if dot.Dot.sick_count < 0: dot.Dot.sick_count = 0
    if dot.Dot.infected_count < 0: dot.Dot.infected_count = 0
    if dot.Dot.immune_count < 0: dot.Dot.immune_count = 0        

# Start of main code.

pygame.init()
screen = pygame.display.set_mode([750, 750])
timer  = pygame.time.Clock()

### Dot creation.

while len(dots) < 100:
    home = (random.randint(0,750),random.randint(0,750))
    work = (random.randint(0,750),random.randint(0,750))
    d = dot.Dot(home,work)
    if negate_repeat() is False:
        dots.append(d)
        sprites.add(d)
        
random_immune()
random_sickness()

### Visuals and Game Logistics

screen.fill((255,255,255))

running = True
while running:

    for event in pygame.event.get():
Exemple #25
0
    "Dead": (0, 0, 0)  # Black
}
# Create Sprites
all_sprites_list = pygame.sprite.Group()
dotList = []

infection_origin = random.randint(75, 100)
# makes 25% not follow SIP and creates 90% of those who don't follow SIP
# follow SD6 and creates one dot that is infected and doesn't follow either
for i in range(100):
    if i < 75:
        start = (random.randint(0, 699), random.randint(0, 699))
        end = (start[0], start[1])
        state = "Healthy"
        size = 5
        dotObj = dot.Dot(start, end, state, size)
        dotList.append(dotObj)
        all_sprites_list.add(dotObj)
    elif i == infection_origin:
        start = (random.randint(0, 699), random.randint(0, 699))
        end = (random.randint(0, 699), random.randint(0, 699))
        state = "Infected"
        size = 5
        dotObj = dot.Dot(start, end, state, size, False, False)
        dotList.append(dotObj)
        all_sprites_list.add(dotObj)
    elif i > 75 and i < 98:
        start = (random.randint(0, 699), random.randint(0, 699))
        end = (random.randint(0, 699), random.randint(0, 699))
        state = "Healthy"
        size = 5
Exemple #26
0
 def test_update_no_of_boxes_of_players(self):
     self._quick_setup_boxes(0, 0)
     boxes = [None, None]
     self.mygame.update_no_of_boxes_of_players(0, boxes)
     self.assertEqual(self.mygame.no_of_boxes_of_players[0], 0)
     self.assertEqual(self.mygame.no_of_boxes_of_players[1], 0)
     self.mygame.update_no_of_boxes_of_players(1, boxes)
     self.assertEqual(self.mygame.no_of_boxes_of_players[0], 0)
     self.assertEqual(self.mygame.no_of_boxes_of_players[1], 0)
     self._quick_setup_boxes(3, 4)
     boxes = [[[dot.Dot([0, 1]), dot.Dot([0, 2])],
               [dot.Dot([0, 2]), dot.Dot([1, 2])],
               [dot.Dot([1, 1]), dot.Dot([1, 2])],
               [dot.Dot([0, 1]), dot.Dot([1, 1])]],
              [[dot.Dot([0, 2]), dot.Dot([0, 3])],
               [dot.Dot([1, 2]), dot.Dot([1, 3])],
               [dot.Dot([0, 3]), dot.Dot([1, 3])],
               [dot.Dot([0, 2]), dot.Dot([1, 2])]]]
     self.mygame.update_no_of_boxes_of_players(0, boxes)
     self.assertEqual(self.mygame.no_of_boxes_of_players[0], 4)
     self.assertEqual(self.mygame.no_of_boxes_of_players[1], 4)
     [box1, _] = boxes
     self._quick_setup_boxes(4, 2)
     self.mygame.update_no_of_boxes_of_players(1, [box1, None])
     self.assertEqual(self.mygame.no_of_boxes_of_players[0], 4)
     self.assertEqual(self.mygame.no_of_boxes_of_players[1], 3)
Exemple #27
0
import dot
import time

to = time.time()
print("Time init: ", to)
obj = dot.Dot()

while True:
    if obj.EventMovement():
        obj.move_dot()  
        print("Tempo percorrido até o click(s): ", time.time()-to)
    if obj.isToClose():
        break

obj.exit_window()
Exemple #28
0
    def setUp(self):
        self.rows = 4
        self.cols = 4
        self.no_of_players = 2
        self.mygame = game.Game([self.rows, self.cols], self.no_of_players)

        # Position shown in figure 1)
        self.list_of_lines_drawn = [
            [dot.Dot([0, 0]), dot.Dot([0, 1])],
            [dot.Dot([1, 1]), dot.Dot([2, 1])],
            [dot.Dot([3, 0]), dot.Dot([3, 1])],
            [dot.Dot([3, 1]), dot.Dot([3, 2])],
            [dot.Dot([3, 2]), dot.Dot([3, 3])],
            [dot.Dot([1, 3]), dot.Dot([2, 3])],
            [dot.Dot([1, 2]), dot.Dot([1, 3])],
            [dot.Dot([0, 0]), dot.Dot([1, 0])],
            [dot.Dot([0, 3]), dot.Dot([1, 3])],
            [dot.Dot([2, 2]), dot.Dot([3, 2])],
            [dot.Dot([2, 3]), dot.Dot([3, 3])],
            [dot.Dot([1, 2]), dot.Dot([2, 2])],
        ]
Exemple #29
0
import matplotlib
matplotlib.rcParams['text.usetex'] = True
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy

import constants
import dot
import space

if __name__ == '__main__':
    earth = dot.Dot()
    earth.mass = constants.EARTH.MASS

    moon = dot.Dot()
    moon.mass = constants.MOON.MASS
    moon.pos[0] = constants.MOON.PERIGEE_ORBIT_RADIUS
    moon.vel[1] = constants.MOON.MAX_ORBITAL_VELOCITY
    moon.vel[2] = 20

    earth.vel[
        1] = -constants.MOON.MAX_ORBITAL_VELOCITY * moon.mass / earth.mass

    test_space = space.Space(dots=[earth, moon])

    print()
    print(test_space)

    n_loops = 3
    n_iterations = 1000
    results = numpy.zeros(shape=(n_iterations, 12))
Exemple #30
0
 def test_box_formed_by(self):
     nonelist = [None, None]
     boxes = [[[dot.Dot([1, 2]), dot.Dot([1, 3])],
               [dot.Dot([1, 3]), dot.Dot([2, 3])],
               [dot.Dot([2, 2]), dot.Dot([2, 3])],
               [dot.Dot([1, 2]), dot.Dot([2, 2])]],
              [[dot.Dot([2, 2]), dot.Dot([2, 3])],
               [dot.Dot([2, 3]), dot.Dot([3, 3])],
               [dot.Dot([3, 2]), dot.Dot([3, 3])],
               [dot.Dot([2, 2]), dot.Dot([3, 2])]]]
     self._quick_check_box(
         self.list_of_lines_drawn,
         [dot.Dot([2, 2]), dot.Dot([2, 3])], boxes, True)
     self._quick_check_box(
         [], [dot.Dot([0, 0]), dot.Dot([0, 1])], nonelist, False)
     self._quick_check_box(
         [[dot.Dot([0, 0]), dot.Dot([0, 1])],
          [dot.Dot([1, 0]), dot.Dot([0, 0])],
          [dot.Dot([0, 1]), dot.Dot([1, 1])],
          [dot.Dot([3, 0]), dot.Dot([3, 1])]],
         [dot.Dot([1, 0]), dot.Dot([1, 1])], nonelist, False)
     self._quick_check_box(
         [[dot.Dot([0, 0]), dot.Dot([0, 1])],
          [dot.Dot([1, 0]), dot.Dot([0, 0])],
          [dot.Dot([0, 1]), dot.Dot([1, 1])],
          [dot.Dot([3, 0]), dot.Dot([3, 1])]],
         [dot.Dot([1, 0]), dot.Dot([1, 1])], nonelist, False)