示例#1
0
 def get_data(self, parameters: dict, x0: float, y0: float, min_t: float, max_t: float, subdivisions: int) -> list:
     x, y = self.get_prediction(parameters, x0, y0)
     data = []
     for i in range(subdivisions):
         t = lerp(min_t, max_t, i/(subdivisions-1))
         data.append((t, x(t), y(t)))
     return data
 def y(t):
     # check whether the value of t is not too large or too small
     if t < 0 or t > self.max_t:
         raise ModelException("t={} out of bounds".format(t))
     # find the indices of the nearest points in time for which the amount was computed
     index = math.floor(t / self.dt)
     next_index = math.ceil(t / self.dt)
     # interpolate
     if index == next_index:
         return y_values[index]
     else:
         return lerp(y_values[index], y_values[index + 1],
                     t / self.dt - index)
示例#3
0
 def y(t):
     # check whether the value of t is not too large or too small
     if t < 0 or t > self.max_t:
         raise ModelException("t={} out of bounds".format(t))
     # find the indices of the nearest points in time for which the amount was computed
     index = math.floor(t * steps_per_time)
     next_index = math.ceil(t * steps_per_time)
     # interpolate
     if index == next_index:
         return result[index, 1]
     else:
         return lerp(result[index, 1], result[index + 1, 1],
                     t * steps_per_time - index)