Exemplo n.º 1
0
def testIntersection():
    #cv1 = np.array([(0.0, 0.0), (1.0, 1.0), (2.0, 1.0), (3.0, 0.0)])
    #cv2 = np.array([(0.0, 1.0), (1.0, 0.0), (2.0, 2.0), (3.0, 3.0)])

    cv1 = np.random.rand(4, 2)
    cv2 = np.random.rand(4, 2)

    ps1 = splinePoints(cv1)
    ps2 = splinePoints(cv2)

    plt.plot(ps1[:, 0], ps1[:, 1], "-")
    plt.plot(ps2[:, 0], ps2[:, 1], "-")

    intersect_points, bb1_list, bb2_list = polylineIntersect(ps1, ps2)

    for bb1, bb2 in zip(bb1_list, bb2_list):
        plotBoundingBox(bb1)
        plotBoundingBox(bb2)

    print intersect_points
    print "num_intersects: %s" %len(intersect_points)

    if len(intersect_points) > 0:
        plt.plot(intersect_points[:, 0], intersect_points[:, 1], "o")
    showMaximize()
Exemplo n.º 2
0
def datasetFunc(data_name):
    scene = loadData(data_name)
    data_list = computeData(scene)

    plotter = ScenePlotter(scene, plt)

    plt.title('Arc Interpolation')
    plotter.showNormalImage()

    for data in data_list:
        error_colors = scalarToColor(data["normals_error"])

        plotSegment(plt, data["ps"], error_colors)

    showMaximize()
Exemplo n.º 3
0
def datasetFunc(data_name):
    scene = loadData(data_name)

    plotter = ScenePlotter(scene, plt)
    silhouette_plotter = plotter.silhouettePlotter()

    plt.title('Isophote Scene')
    plotter.showNormalImage()
    #silhouette_plotter.plotCVs()
    silhouette_plotter.plotNormalVectors()
    silhouette_plotter.plotCurves(color=(0.1, 0.5, 0.1))

    for isophote_plotter in plotter.isophotePlotters():
        #isophote_plotter.plotCVs()
        isophote_plotter.plotCurves(color=(0.1, 0.1, 0.3))
        isophote_plotter.plotNormalVectors(color=(0.1, 0.1, 0.3), step=5)
    showMaximize()
Exemplo n.º 4
0
        plt.annotate('closest point: %s' % cp, xy=cp)

        Line(p, cp).plotLine(plt)
        Line(self._p, p).plotVector(plt)

if __name__ == '__main__':
    import matplotlib.pyplot as plt
    from inversetoon.plot.window import showMaximize
    l1 = Line((0.0, 0.2), (1.0, 1.0))
    l2 = Line((0.0, 1.0), (1.0, 0.0))
    p = np.array((0.2, 0.6))

    ax = plt.subplot(111)
    ax.set_aspect('1.0')

    l1.plotLine(ax)
    l2.plotLine(ax)

    ip = l1.intersect(l2)
    t = l1.closestParam(ip)

    plt.title("Intersect at t, p: %s, %s" % (t, ip))

    ax.plot(ip[0], ip[1], "o")
    ax.plot(p[0], p[1], "o")

    l1.plotClosetPoint(plt, p)

    ax.set_aspect('1.0')
    showMaximize()