Rolling Ball Expression

   2341   5   1
User Avatar
Member
28 posts
Joined: April 2020
Offline
I have a very simple scene with a top down camera looking down on top of a couple of spheres. Think balls on a billiard table. I want to be able to translate the balls around in x and z and have the ball rotate automatically to match the translation. I can do this with an expression for one of the translations but when I then translate in the second direction the rotation is wrong. How can I achieve this?
Image Not Found
Image Not Found

Attachments:
RollingBall_001.hiplc (419.2 KB)

User Avatar
Member
28 posts
Joined: April 2020
Offline
Image Not Found

Attachments:
RollingBall_001.mp4 (138.6 KB)

User Avatar
Member
8177 posts
Joined: Sept. 2011
Online
For a simple constant motion, a simple linear relationship can be calculated for the rolling amount. However, if the movement changes direction, the rolling needs to be integrated using calculus meaning a simple expression cannot be used. Integrating Euler rotation values is also not simple, so quaternions work best for integrating the change in rotation over each time step. Unfortunately, the channel tools don't make working with quaternions very easy and an iterative solve of the rotation is easier done in SOPs by loading in all of the time samples as points. Then the time samples can be turned into an array and solved at once. The rotation 'odometer' quaternion can be turned back into a Euler rotation and exported back as the channels for the object.

Attachments:
rolling_constraint1.hip (379.7 KB)
untitled.mp4 (4.7 MB)

User Avatar
Member
28 posts
Joined: April 2020
Offline
That's awesome. Thank you so much for setting up the file for me and the excellent explanation. There's no way I would have figured this out on my own.
User Avatar
Member
8177 posts
Joined: Sept. 2011
Online
DarrynRogers
That's awesome. Thank you so much for setting up the file for me and the excellent explanation. There's no way I would have figured this out on my own.

Yeah, it's one of those things that's simple for the simple case, but is dramatically more complex for the dynamic case. There's other ways to solve this of course, such as using an RBD simulation.
User Avatar
Member
28 posts
Joined: April 2020
Offline
This one has to be keyframed because I need to roll the balls around to very specific locations. But having your rig is going to save me so much time now that I won't have to manually keyframe the rotations. The result is going to be a lot more accurate too.
  • Quick Links