def main():
    print('Spline 2D test')
    import matplotlib.pyplot as plt
    x = [(- 2.5), 0.0, 2.5, 5.0, 7.5, 3.0, (- 1.0)]
    y = [0.7, (- 6), 5, 6.5, 0.0, 5.0, (- 2.0)]
    ds = 0.1
    sp = Spline2D(x, y)
    s = np.arange(0, sp.s[(- 1)], ds)
    (rx, ry, ryaw, rk) = ([], [], [], [])
    for i_s in s:
        (ix, iy) = sp.calc_position(i_s)
        rx.append(ix)
        ry.append(iy)
        ryaw.append(sp.calc_yaw(i_s))
        rk.append(sp.calc_curvature(i_s))
    plt.plot(rx, ry)
    plt.show()
    plt.close()
    plt.subplots(1)
    plt.plot(x, y, 'xb', label='input')
    plt.plot(rx, ry, '-r', label='spline')
    plt.grid(True)
    plt.axis('equal')
    plt.xlabel('x[m]')
    plt.ylabel('y[m]')
    plt.legend()
    plt.subplots(1)
    plt.plot(s, [np.rad2deg(iyaw) for iyaw in ryaw], '-r', label='yaw')
    plt.grid(True)
    plt.legend()
    plt.xlabel('line length[m]')
    plt.ylabel('yaw angle[deg]')
    plt.subplots(1)
    plt.plot(s, rk, '-r', label='curvature')
    plt.grid(True)
    plt.legend()
    plt.xlabel('line length[m]')
    plt.ylabel('curvature [1/m]')
    plt.show()
def main():
    print('Spline 2D test')
    import matplotlib.pyplot as plt
    x = [(- 2.5), 0.0, 2.5, 5.0, 7.5, 3.0, (- 1.0)]
    y = [0.7, (- 6), 5, 6.5, 0.0, 5.0, (- 2.0)]
    ds = 0.1
    sp = Spline2D(x, y)
    s = np.arange(0, sp.s[(- 1)], ds)
    (rx, ry, ryaw, rk) = ([], [], [], [])
    for i_s in s:
        (ix, iy) = sp.calc_position(i_s)
        rx.append(ix)
        ry.append(iy)
        ryaw.append(sp.calc_yaw(i_s))
        rk.append(sp.calc_curvature(i_s))
    plt.plot(rx, ry)
    plt.show()
    plt.close()
    plt.subplots(1)
    plt.plot(x, y, 'xb', label='input')
    plt.plot(rx, ry, '-r', label='spline')
    plt.grid(True)
    plt.axis('equal')
    plt.xlabel('x[m]')
    plt.ylabel('y[m]')
    plt.legend()
    plt.subplots(1)
    plt.plot(s, [np.rad2deg(iyaw) for iyaw in ryaw], '-r', label='yaw')
    plt.grid(True)
    plt.legend()
    plt.xlabel('line length[m]')
    plt.ylabel('yaw angle[deg]')
    plt.subplots(1)
    plt.plot(s, rk, '-r', label='curvature')
    plt.grid(True)
    plt.legend()
    plt.xlabel('line length[m]')
    plt.ylabel('curvature [1/m]')
    plt.show()