Exemplo n.º 1
0
def create_arc(length,
               curvature,
               current_road,
               start_s,
               hardCode=False,
               quad_number=10):
    """ Gives the chord line set of points for a curved road"""
    plt = [[], []]

    anti_clockwise = 1
    tangent = Vector(1, 0, 0)
    radius = 1 / curvature
    end_angle = 0
    if (radius > 0):
        tangent = tangent.rotate(90)
        anti_clockwise = 1
    else:
        tangent = tangent.rotate(-90)
        radius = -1 * radius
        anti_clockwise = -1
    center = radius * tangent
    tangent = tangent.rotate(180)
    start_angle = tangent.argument()
    end_angle = start_angle + anti_clockwise * 360 * (length /
                                                      (2 * math.pi * radius))
    angle = start_angle
    radius = Vector(radius, 0, 0)
    radius = radius.rotate(start_angle)
    tot_lane_vertices = []
    s = -0.1
    for i in range(quad_number + 1):
        pt = center + radius
        lane_data = current_road.get_lane_data(s + start_s)
        current_pt = pt + Vector(0, 0, current_road.get_elevation(s + start_s))
        lane_pts = generate_lane_verts(current_pt,
                                       radius.rotate(90 * anti_clockwise),
                                       lane_data, hardCode)
        tot_lane_vertices.append(lane_pts)
        radius = radius.rotate((end_angle - start_angle) / quad_number)
        plt[0].append(pt.x)
        plt[1].append(pt.y)
        dTheta = (end_angle - start_angle) / quad_number
        dTheta = dTheta * 3.14 / 180
        s = s + radius.norm() * dTheta
    return tot_lane_vertices