def test_get_average_vector(self):
     lines = [self.create_simple_line_seg((0, 0), (1, 1)), \
              self.create_simple_line_seg((1, 1), (3, -7)), \
              self.create_simple_line_seg((1, 0), (-4, 4)), \
              self.create_simple_line_seg((4, 2), (1, -3))]
     self.assertEquals(get_average_vector(lines), Vec2(11, -8))
     self.assertEquals(get_average_vector([self.create_simple_line_seg((0, 1), (2, 9))]), Vec2(2, 8))
Ejemplo n.º 2
0
 def test_get_average_vector(self):
     lines = [self.create_simple_line_seg((0, 0), (1, 1)), \
              self.create_simple_line_seg((1, 1), (3, -7)), \
              self.create_simple_line_seg((1, 0), (-4, 4)), \
              self.create_simple_line_seg((4, 2), (1, -3))]
     self.assertEquals(get_average_vector(lines), Vec2(11, -8))
     self.assertEquals(
         get_average_vector([self.create_simple_line_seg((0, 1), (2, 9))]),
         Vec2(2, 8))
Ejemplo n.º 3
0
def get_representative_line_from_trajectory_line_segments(trajectory_line_segments, min_vertical_lines, min_prev_dist):
    average_trajectory_vector = get_average_vector(line_segment_list=map(lambda x: x.line_segment, trajectory_line_segments))
    
    for traj_line_seg in trajectory_line_segments:
        traj_line_seg.line_segment = get_rotated_line_segment(traj_line_seg.line_segment, \
                                                              - average_trajectory_vector.angle)
        
    representative_points = get_representative_line_from_rotated_line_segments(trajectory_line_segments=trajectory_line_segments, \
                                                                               min_vertical_lines=min_vertical_lines, \
                                                                               min_prev_dist=min_prev_dist)
    return map(lambda x: x.rotated(angle=average_trajectory_vector.angle), representative_points)
Ejemplo n.º 4
0
def get_rline_pts(tls_list, min_vline, min_prev_dist):
    segments = list(map(lambda tls: tls.segment, tls_list))
    avg_vec = get_average_vector(segments)
    for tls in tls_list:
        tls.rsegment = get_rotated_segment(tls.segment, -avg_vec.angle)
    inputs = get_representative_trajectory_average_inputs(
        tls_list, min_vline, min_prev_dist)
    rline_pts = []
    for line_seg_averaging_input in inputs:
        vert_val = get_mean_vertical_coordinate_in_line_segments(
            line_seg_averaging_input)
        rline_pts.append(
            Point(line_seg_averaging_input['horizontal_position'], vert_val))
    return [pt.rotated(avg_vec.angle) for pt in rline_pts]
 def test_gets_average_vector_of_diamond(self):
     lines = [self.create_simple_line_seg((0, 100), (100, 200)), \
              self.create_simple_line_seg((100, 200), (200, 100)), \
              self.create_simple_line_seg((200, 100), (100, 0)), \
              self.create_simple_line_seg((100, 0), (0, 100))]
     self.assertEquals(get_average_vector(lines), Vec2(400, 0))
Ejemplo n.º 6
0
 def test_gets_average_vector_of_diamond(self):
     lines = [self.create_simple_line_seg((0, 100), (100, 200)), \
              self.create_simple_line_seg((100, 200), (200, 100)), \
              self.create_simple_line_seg((200, 100), (100, 0)), \
              self.create_simple_line_seg((100, 0), (0, 100))]
     self.assertEquals(get_average_vector(lines), Vec2(400, 0))