def plot_chain(chain, joints, ax, target=None, show=False):
    """Plots the chain"""
    # LIst of nodes and orientations
    nodes = []
    axes = []

    transformation_matrixes = chain.forward_kinematics(joints, full_kinematics=True)

    # Get the nodes and the orientation from the tranformation matrix
    for (index, link) in enumerate(chain.links):
        (node, rotation) = geometry_utils.from_transformation_matrix(transformation_matrixes[index])
        nodes.append(node)
        rotation_axis = link._get_rotation_axis()
        if index == 0:
            axes.append(rotation_axis)
        else:
            axes.append(geometry_utils.homogeneous_to_cartesian_vectors(np.dot(transformation_matrixes[index - 1], rotation_axis)))

    # Plot the chain
    ax.plot([x[0] for x in nodes], [x[1] for x in nodes], [x[2] for x in nodes])
    # Plot of the nodes of the chain
    ax.scatter([x[0] for x in nodes], [x[1] for x in nodes], [x[2] for x in nodes])

    # Plot  rotation axes
    for index, axe in enumerate(axes):
        ax.plot([nodes[index][0], axe[0]], [nodes[index][1], axe[1]], [nodes[index][2], axe[2]])
Plots the chain