Skip to content

Commit

Permalink
Merge pull request #55 from kaseris/fix/transforms
Browse files Browse the repository at this point in the history
Clamp the values in the range [-1, 1] to avoid errors
  • Loading branch information
kaseris committed Dec 14, 2023
2 parents 28ccd3e + ebda93b commit 396c11b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/skelcast/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def xyz_to_expmap(xyz_seq, parents):
cross_vecs = np.cross(norm_parent_bones, norm_bones)
norm_cross_vecs = _norm_bvecs(cross_vecs)
# dot products give us rotation angle
angles = np.arccos(np.sum(norm_bones * norm_parent_bones, axis=-1))
cos_values = np.sum(norm_bones * norm_parent_bones, axis=-1)
clamped_cos_values = np.clip(cos_values, -1.0, 1.0)
angles = np.arccos(clamped_cos_values)
log_map = norm_cross_vecs * angles[..., None]
exp_seq[:, child] = log_map

Expand Down

0 comments on commit 396c11b

Please sign in to comment.