# Quartic Hermite curve interpolation - help needed

Hi guys, I’m trying to translate speed curve into time values for TimewarpML in order to match flame one and I’m a bit confused as it seem to use quartic interpolation.

I have a code for cubic interpolation that works perfectly for a speed curve:

``````    class HermiteSegment(LinearSegment):
def __init__(self, from_frame, to_frame, value1, value2, tangent1, tangent2):
self.start_frame, self.end_frame = from_frame, to_frame
frame_interval = (self.end_frame - self.start_frame)
self._mode = 'hermite'

self.HERMATRIX = np.array([
[2,  -2,  1,  1],
[-3, 3,   -2, -1],
[0,   0,  1,  0],
[1,   0,  0,  0]
])

# Default tangents in flame are 0, so when we do None.to_f this is what we will get
# CC = {P1, P2, T1, T2}
p1, p2, t1, t2 = value1, value2, tangent1 * frame_interval, tangent2 * frame_interval
self.hermite = np.array([p1, p2, t1, t2])
self.basis = np.dot(self.HERMATRIX, self.hermite)

def value_at(self, frame):
if frame == self.start_frame:
return self.hermite

# Get the 0 < T < 1 interval we will interpolate on
# Q[frame_] = P[ ( frame - 149 ) / (time_to - time_from)]
t = (frame - self.start_frame) / (self.end_frame - self.start_frame)

# S[s_] = {s^3, s^2, s^1, s^0}
multipliers_vec = np.array([t ** 3, t ** 2, t ** 1, t ** 0])

# P[s_] = S[s].h.CC
interpolated_scalar = np.dot(self.basis, multipliers_vec)
return interpolated_scalar
``````

Could someone advice how to perform quartic interpolation for SpeedTiming curve?
I’ve tried to google quartic hermite matrix and even asked chatgpt but got no luck so far…

Thank you!
Andriy.