MCPcopy Index your code
hub / github.com/MotrixLab/MotionDiffuse / get_quaternion

Function get_quaternion

text2motion/utils/motion_process.py:76–96  ·  view source on GitHub ↗
(positions)

Source from the content-addressed store, hash-verified

74 return positions
75
76 def get_quaternion(positions):
77 skel = Skeleton(n_raw_offsets, kinematic_chain, "cpu")
78 # (seq_len, joints_num, 4)
79 quat_params = skel.inverse_kinematics_np(positions, face_joint_indx, smooth_forward=False)
80
81 '''Fix Quaternion Discontinuity'''
82 quat_params = qfix(quat_params)
83 # (seq_len, 4)
84 r_rot = quat_params[:, 0].copy()
85 # print(r_rot[0])
86 '''Root Linear Velocity'''
87 # (seq_len - 1, 3)
88 velocity = (positions[1:, 0] - positions[:-1, 0]).copy()
89 # print(r_rot.shape, velocity.shape)
90 velocity = qrot_np(r_rot[1:], velocity)
91 '''Root Angular Velocity'''
92 # (seq_len - 1, 4)
93 r_velocity = qmul_np(r_rot[1:], qinv_np(r_rot[:-1]))
94 quat_params[1:, 0] = r_velocity
95 # (seq_len, joints_num, 4)
96 return quat_params, r_velocity, velocity, r_rot
97
98 def get_cont6d_params(positions):
99 skel = Skeleton(n_raw_offsets, kinematic_chain, "cpu")

Callers

nothing calls this directly

Calls 6

inverse_kinematics_npMethod · 0.95
SkeletonClass · 0.90
qfixFunction · 0.85
qrot_npFunction · 0.85
qmul_npFunction · 0.85
qinv_npFunction · 0.85

Tested by

no test coverage detected