def get_vertices_to_edges_matrix(self, want_xyz=True):
        """Returns a matrix M, which if multiplied by vertices,
        gives back edges (so "e = M.dot(v)"). Note that this generates
        one edge per edge, *not* two edges per triangle.

        Args:
            want_xyz: if true, takes and returns xyz coordinates, otherwise
                takes and returns x *or* y *or* z coordinates
        """
        import numpy as np
        import scipy.sparse as sp

        vpe = np.asarray(self.vertices_per_edge, dtype=np.int32)
        IS = np.repeat(np.arange(len(vpe)), 2)
        JS = vpe.flatten()
        data = np.ones_like(vpe)
        data[:, 1] = -1
        data = data.flatten()

        if want_xyz:
            IS = np.concatenate((IS*3, IS*3+1, IS*3+2))
            JS = np.concatenate((JS*3, JS*3+1, JS*3+2))
            data = np.concatenate((data, data, data))

        ij = np.vstack((IS.flatten(), JS.flatten()))
        return sp.csc_matrix((data, ij))
def get_vertices_to_edges_matrix ( self , want_xyz = True ) : import numpy as np import scipy . sparse as sp vpe = np . asarray ( self . vertices_per_edge , dtype = np . int32 ) IS = np . repeat ( np . arange ( len ( vpe ) ) , 2 ) JS = vpe . flatten ( ) data = np . ones_like ( vpe ) data [ : , 1 ] = - 1 data = data . flatten ( ) if want_xyz : IS = np . concatenate ( ( IS * 3 , IS * 3 + 1 , IS * 3 + 2 ) ) JS = np . concatenate ( ( JS * 3 , JS * 3 + 1 , JS * 3 + 2 ) ) data = np . concatenate ( ( data , data , data ) ) ij = np . vstack ( ( IS . flatten ( ) , JS . flatten ( ) ) ) return sp . csc_matrix ( ( data , ij ) )
Returns a matrix M, which if multiplied by vertices,
        gives back edges (so "e = M.dot(v)"). Note that this generates
        one edge per edge, *not* two edges per triangle.

        Args:
            want_xyz: if true, takes and returns xyz coordinates, otherwise
                takes and returns x *or* y *or* z coordinates