Skip to content

rig_curve_geometry

rig_curve_geometry(P0, pI)

From the global affine matrix of each bone, and each bone's parent index, make a bidirectional edge simplex representing the rig

Parameters:

Name Type Description Default
P0 (b, 3, 4) numpy float array

The world affine matrix of each bone

required
pI (b, 1) numpy int array

The parent index of each bone

required

Returns:

Name Type Description
rV (V, 3) numpy float array

The vertex geometry of the rig edge simplex

rE (e, 2) numpy int array

The edge list of the rig edge simplex

Source code in src\fast_cody\rig_curve_geometry.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
def rig_curve_geometry(P0, pI):
    """
    From the global affine matrix of each bone, and each bone's parent index, make a bidirectional
    edge simplex representing the rig

    Parameters
    ----------
    P0 : (b, 3, 4) numpy float  array
        The world affine matrix of each bone
    pI : (b, 1)  numpy int array
        The parent index of each bone

    Returns
    -------
    rV : (V, 3) numpy float array
        The vertex geometry of the rig edge simplex
    rE : (e, 2) numpy int array
        The edge list of the rig edge simplex

    """

    assert(pI.shape[0] > 1)
    assert(P0.shape[0] == pI.shape[0])
    rV = P0[:, :,3]

    rE = np.zeros((0, 2), dtype=np.int32)
    # fill out E, the edge list
    for i in range(len(pI)):
        if (pI[i] == -1):
            continue
        else:
            # make a bidirectional edge between
           #i and pI[i]
            ei = np.array([[i, pI[i]]])
            # stack it on top of rE
            rE = np.vstack((rE, ei))

    # import polyscope as ps
    # ps.init()
    # ps.register_curve_network("rig", rV, rE)
    # ps.register_point_cloud("rV", rV)
    # ps.show()


    return rV, rE