Exemplo n.º 1
0
 def _interpolate_p0_p1(self):
     """Interpolate between p0 and p1, but do not step or clear"""
     pt0p, pt0 = self._pt0_prev, self._pt0
     pt1, pt1n = self._pt1, self._pt1_next
     can_interp = (pt0 is not None and pt1 is not None
                   and len(self._np) > 0)
     if can_interp:
         if pt0p is None:
             pt0p = pt0
         if pt1n is None:
             pt1n = pt1
         t0 = pt0[0]
         t1 = pt1[0]
         dt = t1 - t0
         can_interp = dt > 0
     if can_interp:
         for np in self._np:
             t, x, y = np[0:3]
             p, xt, yt = spline_4p(
                 float(t - t0) / dt, array(pt0p[3:]), array(pt0[3:]),
                 array(pt1[3:]), array(pt1n[3:]))
             p = clamp(p, 0.0, 1.0)
             xt = clamp(xt, -1.0, 1.0)
             yt = clamp(yt, -1.0, 1.0)
             yield (t, x, y, p, xt, yt)
     if pt1 is not None:
         yield pt1
Exemplo n.º 2
0
 def _interpolate_p0_p1(self):
     """Interpolate between p0 and p1, but do not step or clear"""
     pt0p, pt0 = self._pt0_prev, self._pt0
     pt1, pt1n = self._pt1, self._pt1_next
     can_interp = (pt0 is not None and pt1 is not None
                   and len(self._np) > 0)
     if can_interp:
         if pt0p is None:
             pt0p = pt0
         if pt1n is None:
             pt1n = pt1
         t0 = pt0[0]
         t1 = pt1[0]
         dt = t1 - t0
         can_interp = dt > 0
     if can_interp:
         for event in self._np:
             t, x, y = event[0:3]
             p, xt, yt, vz, vr = spline_4p((t - t0) / dt,
                                           np.array(pt0p[3:]),
                                           np.array(pt0[3:]),
                                           np.array(pt1[3:]),
                                           np.array(pt1n[3:]))
             yield (t, x, y, p, xt, yt, vz, vr)
     if pt1 is not None:
         yield pt1
Exemplo n.º 3
0
 def _interpolate_p0_p1(self):
     """Interpolate between p0 and p1, but do not step or clear"""
     pt0p, pt0 = self._pt0_prev, self._pt0
     pt1, pt1n = self._pt1, self._pt1_next
     can_interp = ( pt0 is not None and pt1 is not None and
                    len(self._np) > 0 )
     if can_interp:
         if pt0p is None:
             pt0p = pt0
         if pt1n is None:
             pt1n = pt1
         t0 = pt0[0]
         t1 = pt1[0]
         dt = t1 - t0
         can_interp = dt > 0
     if can_interp:
         for np in self._np:
             t, x, y = np[0:3]
             p, xt, yt = spline_4p(
                 float(t - t0) / dt,
                 array(pt0p[3:]), array(pt0[3:]),
                 array(pt1[3:]), array(pt1n[3:])
             )
             p = clamp(p, 0.0, 1.0)
             xt = clamp(xt, -1.0, 1.0)
             yt = clamp(yt, -1.0, 1.0)
             yield (t, x, y, p, xt, yt)
     if pt1 is not None:
         yield pt1
Exemplo n.º 4
0
 def _interpolate_p0_p1(self):
     """Interpolate between p0 and p1, but do not step or clear"""
     pt0p, pt0 = self._pt0_prev, self._pt0
     pt1, pt1n = self._pt1, self._pt1_next
     can_interp = (pt0 is not None and pt1 is not None and
                   len(self._np) > 0)
     if can_interp:
         if pt0p is None:
             pt0p = pt0
         if pt1n is None:
             pt1n = pt1
         t0 = pt0[0]
         t1 = pt1[0]
         dt = t1 - t0
         can_interp = dt > 0
     if can_interp:
         for event in self._np:
             t, x, y = event[0:3]
             p, xt, yt = spline_4p(
                 (t - t0) / dt,
                 np.array(pt0p[3:]), np.array(pt0[3:]),
                 np.array(pt1[3:]), np.array(pt1n[3:])
             )
             yield (t, x, y, p, xt, yt)
     if pt1 is not None:
         yield pt1