Search - User list
Full Version: How can I calculate slope/accel in a hou.Keyframe by myself?
Root » Technical Discussion » How can I calculate slope/accel in a hou.Keyframe by myself?
alexmajewski
I would like to control the handles of keyframes in the Animation Editor panel with Python and set them programmatically. I don't understand the math behind slope/accel.




To give an example, let's say I want to write a script that automatically finds the right length for handles to be approx. one third of the possible length.



Or a script that maps handle presets to the selected keyframes proportionally. Where could I start?

I was only able to figure out that when the slope is 0, accel can be calculated from .time() alone. But I don't know what slope and accel are mathematically.

I'll appreciate any help.
alexmajewski
Some discoveries if anyone finds this in the future:
Slope is tan(angle_in_radians)
Accel is the handle's value of the vertical axis, unless approaching slope 0, then it suddenly becomes time in seconds, so the value of the horizontal axis. Maybe it uses max(vertical_value, time)I don't know yet.
tamte
from a quick look to me it looks like:

- slope is as you said the tan of handle's angle: y/x
- accel is length of the hande: sqrt( x*x + y*y )

where x is handle's x coordinate in seconds and y is the value on y axis
alexmajewski
I wasn't familiar with this equation, I now see it's a basic distance formula. Very cool! Thanks Tomas. I learned something today. Now I see the slope/accel is just tan and distance.
Jonathan de Blok
If you check the source of this tool you can find some math regarding handles and bezier curves.

Link to the tool is on the video description, The video itself is a bit outdated and there are some extra feature added but the core principle is the same, making it easy to manage animation flow on complex paths, I use it a lot to get nice and consistent camera moves and to make nice swoosh effects


alexmajewski
That's awesome, looks seriously useful. I'm working on a similar tool! But of course mine will be different. Thanks for sharing
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB