Пример #1
0
def plot_skeleton_on_axes3d(skel,
                            skel_desc,
                            ax: Axes3D,
                            invert=True,
                            alpha=1.0):
    ax.set_xlabel('x')
    ax.set_ylabel('z')
    ax.set_zlabel('y')

    # NOTE: y and z axes are swapped
    xs = skel.narrow(-1, 0, 1).numpy()
    ys = skel.narrow(-1, 2, 1).numpy()
    zs = skel.narrow(-1, 1, 1).numpy()

    # Correct aspect ratio (https://stackoverflow.com/a/21765085)
    max_range = np.array(
        [xs.max() - xs.min(),
         ys.max() - ys.min(),
         zs.max() - zs.min()]).max() / 2.0
    mid_x = (xs.max() + xs.min()) * 0.5
    mid_y = (ys.max() + ys.min()) * 0.5
    mid_z = (zs.max() + zs.min()) * 0.5
    ax.set_xlim(mid_x - max_range, mid_x + max_range)
    ax.set_ylim(mid_y - max_range, mid_y + max_range)
    ax.set_zlim(mid_z - max_range, mid_z + max_range)
    ax.set_aspect('equal')

    if invert:
        ax.invert_zaxis()

    # Set starting view
    ax.view_init(elev=20, azim=-100)

    get_joint_metadata = _make_joint_metadata_fn(skel_desc)
    for joint_id, joint in enumerate(skel):
        meta = get_joint_metadata(joint_id)
        color = 'magenta'
        if meta['group'] == 'left':
            color = 'blue'
        if meta['group'] == 'right':
            color = 'red'
        parent = skel[meta['parent']]
        offset = parent - joint
        ax.quiver(
            [joint[0]],
            [joint[2]],
            [joint[1]],
            [offset[0]],
            [offset[2]],
            [offset[1]],
            color=color,
            alpha=alpha,
        )

    ax.scatter(xs, ys, zs, color='grey', alpha=alpha)
Пример #2
0
        if x[i] != -1:  #on plote pas les points qui sont sortis des limites du terrains (caractérisés par x=-1)
            xpoints.append(x[i])
            ypoints.append(y[i])
    #plot tous les impacts maintenant
    plt.scatter(xpoints,
                ypoints,
                alpha=0.5,
                color='yellow',
                edgecolors='black')
    #Ploter le cercle d'incetitudes
    theta = np.linspace(0, 2 * np.pi, 100)
    x1 = z[0] * np.cos(theta) + x[
        0]  #On avait mis la taille du rayon du cercle d'incertitudes dans z[0] tandis que x[0] et y[0] sont les coords pt impact sans aléas.
    x2 = z[0] * np.sin(theta) + y[0]
    plt.plot(x1,
             x2,
             '--',
             color='red',
             label="Cercle de similitude (rayon=%.2fm)" % (z[0]))
    plt.scatter(x[0], y[0], color='red')
    plothalftenniscourt2D()
    ax = plt.gca()
    ax.set_aspect(1)
    plt.legend(loc='upper right')
    plt.title(
        "Plot des points d'impacts obtenus lors de la simulation avec aléas")
    plt.savefig("image/vue_impacts_imprécisions" + num + ".SVG")
else:
    #Si on a pas de probas, on creer une figure extrèmement petite et invisible qui sera sur site mais invisible comme ça pas besoin de gerer le cas plus difficilement.
    plt.figure(figsize=(0.1, 0.1))
    plt.savefig("image/vue_impacts_imprécisions" + num + ".SVG")