示例#1
0
def blend(pose1, pose2, alpha=0.5):
    assert 0.0 <= alpha <= 1.0
    pose_new = copy.deepcopy(pose1)
    for j in range(pose1.skel.num_joints()):
        R0, p0 = conversions.T2Rp(pose1.get_transform(j, local=True))
        R1, p1 = conversions.T2Rp(pose2.get_transform(j, local=True))
        R, p = math.slerp(R0, R1, alpha), math.lerp(p0, p1, alpha)
        pose_new.set_transform(j, conversions.Rp2T(R, p), local=True)
    return pose_new
示例#2
0
    def interpolate(cls, v1, v2, alpha):
        """Returns interpolated velocity object between two velocity objects.
        Typically, each velocity object is associated with a frame.
        `interpolate` could be used to calculated interpolated angular and
        linear velocity for any frame between them.

        Args:
            v1, v2: Velocity objects associated with frame between which
                interpolated velocity is calculated
            alpha: Value between 0 and 1 denoting the blending ratio. alpha=0
                returns v1, and alpha=1 returns v2
        """
        data_local = math.lerp(v1.data_local, v2.data_local, alpha)
        data_global = math.lerp(v1.data_global, v2.data_global, alpha)
        v = cls()
        v.set_skel(v1.skel)
        v.set_data_local(data_local)
        v.set_data_global(data_global)
        return v
示例#3
0
 def interpolate(cls, pose1, pose2, alpha):
     skel = pose1.skel
     data = []
     for j in skel.joints:
         R1, p1 = conversions.T2Rp(pose1.get_transform(j, local=True))
         R2, p2 = conversions.T2Rp(pose2.get_transform(j, local=True))
         R, p = (
             math.slerp(R1, R2, alpha),
             math.lerp(p1, p2, alpha),
         )
         data.append(conversions.Rp2T(R, p))
     return Pose(pose1.skel, data)