Skip to main content
Participant
November 9, 2023
Question

How to build the path between adjacent spatial keyframes derived from their values and tangents

  • November 9, 2023
  • 1 reply
  • 351 views

Problem:

1. Calculate TwoD_SPATIAL property path between adjacent keyframes and convert it to a set of "hold" OR "linear" keyframes set to each frame on the distance

 

Restrictions:

1.  We cannot use the api (like property.getValueAtTime(t)), only adjacent keyframes as an input

 

Input: 

  1.  Adjacent keyframes for TwoD_SPATIAL property with some bezier spatial interpolation
  2.  Temporal interpolation for these keyframes can be of any type

My assumption was to:

  1. Build the curve using cubic bezier function based on 4 points: Keyframe1, Keyframe1 Out Tangent, Keyframe 2 In Tangent and Keyframe 2 value
  2. Somehow apply the temporal interpolation, if it's not linear (not solved yet)

 

What I observed:

1. The temporal interpolation was set to Linear just to begin with just defining the curve

2. The points I took for calculation:
P1 = 1st Kf value [x1, y1]

P2 = 1st Kf value - 1st Kf Out tangent = [x1, y1] - [xtn1, ytn1]

P3 = 2nd Kf value - 2nd Kf In tangent = [x2, y2] - [xtn2, ytn2]

P4 = 2nd Kf value = [x2, y2]

3. The formula to build the curve:

x(t) = (1−t)^3 * x1 + 3(1−t)^2 * t * x2 + 3(1−t)* t^2 * x3 + t^3 * x4
y(t) = (1−t)^3 * y1 + 3(1−t)^2 * t * y2 + 3(1−t)* t^2 * y3 + t^3 * y4

For convenience I just calculated values for t = 0.5, but the result didn't match what we have actually in AE in the middle of the path

 

So have next questions:

1. Probably you guys can advice me what's wrong in the assumption that I can build the path curve via creating cubic bezier path (maybe smth with base points to choose)

2. What is the proper way to take into account the temporal interpolation when the path is finally derived

 

Thanks in advance!

 

This topic has been closed for replies.

1 reply

Mylenium
Legend
November 9, 2023

The temporal interpolation equates the U parameter in the Bèzier formula, i.e. the density/ distribution of the calculated intermediate points. The innaccuracies in your result may simply be down to using a simplified formula that has the cubic-ness hardwired. The actual Bezièr formula doesn't make any such assumptions and would produce slightly different values.

 

Mylenium

Participant
November 10, 2023

But can it be smth else then cubic? I'm trying to find the curve between 2 adjacent keyframes, so 4 points at all

I am not so good at Math, so I can be asking silly questions)