Skip to content

lbs_weight_space_constraint

lbs_weight_space_constraint(V, C)

Rewrites a linear equality constraint that acts on per-vertex displacements (CU(W) = 0) to instead act on the per-vertex skinning weights (AW = 0).

Parameters:

Name Type Description Default
V (n, d) float numpy array

Mesh vertices

required
C (c, dn) float numpy array

Linear equality constraint matrix that acts on per-vertex displacements

required

Returns:

Name Type Description
A (n, c') float numpy array

Linear equality constraint matrix that acts on per-vertex skinning weights

Source code in src\fast_cody\lbs_weight_space_constraint.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def lbs_weight_space_constraint(V, C):
    """ Rewrites a linear equality constraint that acts on per-vertex displacements (CU(W) = 0)
        to instead act on the per-vertex skinning weights  (AW = 0).

    Parameters
    ----------
    V : (n, d) float numpy array
        Mesh vertices
    C : (c, dn) float numpy array
        Linear equality constraint matrix that acts on per-vertex displacements

    Returns
    -------
    A : (n, c') float numpy array
        Linear equality constraint matrix that acts on per-vertex skinning weights
    """
    C = C.T
    n = V.shape[0]
    d = V.shape[1]

    v = np.ones((n, 1))

    A = np.zeros((0, n))
    for i in range(0, d):
        Id = np.arange(0, n) + i * n
        Jd = np.arange(0, n)
        Pd = sp.sparse.coo_matrix((v.flatten(), (Id, Jd)), shape=(3*n,n))

        for j in range(0, d):
            Vj = V[:, j]
            Adj = C.T @ Pd @ sp.sparse.diags(Vj, 0)
            A = np.vstack([A, Adj])
        Ad1 = C.T @ Pd
        A = np.vstack([A, Ad1])

    W = A
    W2 = orthonormalize(W.T).T



    return W2