Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep original direction from content motion #198

Open
LeVan146 opened this issue Nov 20, 2021 · 1 comment
Open

Keep original direction from content motion #198

LeVan146 opened this issue Nov 20, 2021 · 1 comment

Comments

@LeVan146
Copy link

LeVan146 commented Nov 20, 2021

Hi guys @kfiraberman @PeizhuoLi, I would be grateful if you can show me how to keep the original direction from content motion?

def y_rotation_from_positions(positions, hips=(2, 6), sdrs=(14, 18)):
"""
input: positions [T, J, 3]
output: quaters: [T, 1, 4], quaternions that rotate the character around the y-axis to face [0, 0, 1]
pivots: [T, 1] in [0, 2pi], the angle from [0, 0, 1] to the current facing direction
"""
across = across_from_glb(positions, hips=hips, sdrs=sdrs)
direction_filterwidth = 20
forward = np.cross(across, np.array([[0, 1, 0]]))
forward = filters.gaussian_filter1d(forward, direction_filterwidth, axis=0, mode='nearest')
forward = forward / np.sqrt((forward ** 2).sum(axis=-1))[..., np.newaxis]
target = np.tile(np.array([0, 0, 1]), forward.shape[:-1] + (1, ))
quaters = Quaternions.between(forward, target)[..., np.newaxis, :] # [T, 4] -> [T, 1, 4]
pivots = Pivots.from_quaternions(-quaters).ps # from "target"[0, 0, 1] to current facing direction "forward"
return quaters, pivots

@PeizhuoLi
Copy link
Collaborator

PeizhuoLi commented Mar 21, 2022

Hi, I'm not sure if understand correctly your question or not.

The code you referred to is taken from Holden's work as described here. We might not be able to provide help on exterior code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants