fly in long curves
359015
def update(self, deltat=1.0):
        ''''''
        DNFZ.update(self, deltat)
        if (self.distance_from_home() > gen_settings.region_width or
            self.getalt() < self.ground_height() or
            self.getalt() > self.ground_height() + 1000):
            self.randpos()
            self.randalt()
100833
def _curve(x1, y1, x2, y2, hunit = HUNIT, vunit = VUNIT):
    
    ax1, ax2, axm = x1 * hunit, x2 * hunit, (x1 + x2) * hunit / 2
    ay1, ay2 = y1 * vunit, y2 * vunit
    return pyx.path.curve(ax1, ay1, axm, ay1, axm, ay2, ax2, ay2)
773010
def fly(cls,
            conf_path,
            docname,
            source,
            maxdepth=1):  # pragma: no cover
        
        msg = ("``.. articles::`` directive is going to be deprecated. "
               "use ``.. autodoctree`` instead.")
        warnings.warn(msg, FutureWarning)

        directive_pattern = ".. articles::"
        if directive_pattern not in source:
            return source

        af = ArticleFolder(
            dir_path=Path(Path(conf_path).parent, docname).parent.abspath)
        toc_directive = af.toc_directive(maxdepth)

        lines = list()
        for line in source.split("\n"):
            if directive_pattern in line.strip():
                if line.strip().startswith(directive_pattern):
                    line = line.replace(directive_pattern, toc_directive, 1)
                    lines.append(line)
                    continue
            lines.append(line)
        return "\n".join(lines)
967784
def move_right(self):
        """"""
        self.at(ardrone.at.pcmd, True, self.speed, 0, 0, 0)
647154
def imitate_path(self, y_des):
        

        # set initial state and goal
        if y_des.ndim == 1: 
            y_des = y_des.reshape(1,len(y_des))
        self.y0 = y_des[:,0].copy()
        self.y_des = y_des.copy()
        self.goal = self.gen_goal(y_des)
        
        self.check_offset()

        if not (self.timesteps == y_des.shape[1]):
            # generate function to interpolate the desired trajectory
            import scipy.interpolate
            path = np.zeros((self.dmps, self.timesteps))
            x = np.linspace(0, self.cs.run_time, y_des.shape[1])
            for d in range(self.dmps):
                path_gen = scipy.interpolate.interp1d(x, y_des[d])
                for t in range(self.timesteps):  
                    path[d, t] = path_gen(t * self.dt)
            y_des = path

        # calculate velocity of y_des
        dy_des = np.diff(y_des) / self.dt
        # add zero to the beginning of every row
        dy_des = np.hstack((np.zeros((self.dmps, 1)), dy_des))

        # calculate acceleration of y_des
        ddy_des = np.diff(dy_des) / self.dt
        # add zero to the beginning of every row
        ddy_des = np.hstack((np.zeros((self.dmps, 1)), ddy_des))

        f_target = np.zeros((y_des.shape[1], self.dmps))
        # find the force required to move along this trajectory
        for d in range(self.dmps):
            f_target[:,d] = ddy_des[d] - self.ay[d] * \
                            (self.by[d] * (self.goal[d] - y_des[d]) - \
                            dy_des[d])

        # efficiently generate weights to realize f_target
        self.gen_weights(f_target)

        '''# plot the basis function activations
        import matplotlib.pyplot as plt
        plt.figure()
        plt.subplot(211)
        plt.plot(psi_track)
        plt.title('psi_track')

        # plot the desired forcing function vs approx
        plt.subplot(212)
        plt.plot(f_target[:,0])
        plt.plot(np.sum(psi_track * self.w[0], axis=1))
        plt.legend(['f_target', 'w*psi'])
        plt.tight_layout()
        plt.show()'''

        self.reset_state()
        return y_des
809149
function takeCurve(pred) {
    for(var i=0, n=horizon.length; i<n; ++i) {
      var c = horizon[i]
      if(pred(c)) {
        horizon[i] = horizon[n-1]
        horizon.pop()
        return c
      }
    }
    return null
  }
248089
private void buildVertexes()
	{
		vertexes.clear();
		if (controlPoints.size() == 0)
			return;

		double step = 1D / (precision + 1);
		double t = 0;
		vertexes.add(controlPoints.get(0));
		for (int i = 1; i <= precision; i++)
		{
			t = i * step;
			vertexes.add(i, interpolateAll(controlPoints, controlPoints.size() - 1, 0, t));
		}
		vertexes.add(controlPoints.get(controlPoints.size() - 1));

		dirty = false;
	}
1300555
def cmdvel2Twist(vel):
    '''
    

    '''
    tw = TwistStamped()
    tw.twist.linear.x = vel.vx
    tw.twist.linear.y = vel.vy
    tw.twist.linear.z = vel.vz
    tw.twist.angular.x = vel.ax
    tw.twist.angular.y = vel.ay
    tw.twist.angular.z = vel.az

    return tw
46783
def curve(bez, draw)
      x1, y1, cx1, cy1 = bez.x1, bez.y1, bez.cx1, bez.cy1
      cx2, cy2, x2, y2 = bez.cx2, bez.cy2, bez.x2, bez.y2
      use_cairo do |cc|
        cc.move_to(x1, y1)
        cc.curve_to(cx1, cy1, cx2, cy2, x2, y2)
        cc.fill_n_stroke(draw)
      end
    end
172037
function(n) {
      // Fitting to the curve is too costly, we compute a larger bounding box
      // using the control points:
      var cp = sigma.utils.getSelfLoopControlPoints(n.x, n.y, n.size);

      // Bounding box of the point and the two control points:
      var minX = Math.min(n.x, cp.x1, cp.x2),
          maxX = Math.max(n.x, cp.x1, cp.x2),
          minY = Math.min(n.y, cp.y1, cp.y2),
          maxY = Math.max(n.y, cp.y1, cp.y2);

      return {
        x1: minX - n.size,
        y1: minY - n.size,
        x2: maxX + n.size,
        y2: minY - n.size,
        height: maxY - minY + n.size * 2
      };
    }
1339317
function tweenLoading(b) {
            let i;

            b.innerRadius = 0;
            i = d3Interpolate.interpolate({ startAngle: 0, endAngle: 0}, b);

            return function(t) { return shape(i(t)); };
        }
560250
def pts_on_bezier_curve(P=[(0.0, 0.0)], n_seg=0):
    '''
    '''
    assert isinstance(P, list)
    assert len(P) > 0
    for p in P:
        assert isinstance(p, tuple)
        for i in p:
            assert len(p) > 1
            assert isinstance(i, float)
    assert isinstance(n_seg, int)
    assert n_seg >= 0
    
    return [pt_on_bezier_curve(P, float(i)/n_seg) for i in range(n_seg)] + [P[-1]]
948517
def curve_subdivide(curve, left, right):
    """"""
    if NO_IMAGES:
        return

    figure = plt.figure()
    ax = figure.gca()
    add_patch(ax, curve._nodes, "gray")
    ax = left.plot(256, ax=ax)
    line = ax.lines[-1]
    add_patch(ax, left._nodes, line.get_color())
    right.plot(256, ax=ax)
    line = ax.lines[-1]
    add_patch(ax, right._nodes, line.get_color())
    ax.axis("scaled")
    ax.set_xlim(-0.125, 2.125)
    ax.set_ylim(-0.125, 3.125)
    save_image(ax.figure, "curve_subdivide.png")
206002
public Curve makeCurve() {
    Curve c = new Curve(curves.size());
    curves.add(c);
    return c;
  }
886622
public Vector4f frustumPlane(int plane, Vector4f planeEquation) {
        switch (plane) {
        case PLANE_NX:
            planeEquation.set(m03 + m00, m13 + m10, m23 + m20, m33 + m30).normalize3(planeEquation);
            break;
        case PLANE_PX:
            planeEquation.set(m03 - m00, m13 - m10, m23 - m20, m33 - m30).normalize3(planeEquation);
            break;
        case PLANE_NY:
            planeEquation.set(m03 + m01, m13 + m11, m23 + m21, m33 + m31).normalize3(planeEquation);
            break;
        case PLANE_PY:
            planeEquation.set(m03 - m01, m13 - m11, m23 - m21, m33 - m31).normalize3(planeEquation);
            break;
        case PLANE_NZ:
            planeEquation.set(m03 + m02, m13 + m12, m23 + m22, m33 + m32).normalize3(planeEquation);
            break;
        case PLANE_PZ:
            planeEquation.set(m03 - m02, m13 - m12, m23 - m22, m33 - m32).normalize3(planeEquation);
            break;
        default:
            throw new IllegalArgumentException("plane"); //$NON-NLS-1$
        }
        return planeEquation;
    }
278913
def validate_known_curve():
    """"""
    plt.figure()
    N = 100
    x = numpy.linspace(-1, 1, N)
    y = numpy.sin(4 * x)
    smoother.DEFAULT_BASIC_SMOOTHER = smoother.BasicFixedSpanSmootherSlowUpdate
    smooth = smoother.perform_smooth(x, y, smoother_cls=supersmoother.SuperSmoother)
    plt.plot(x, smooth.smooth_result, label='Slow')
    smoother.DEFAULT_BASIC_SMOOTHER = smoother.BasicFixedSpanSmoother
    smooth = smoother.perform_smooth(x, y, smoother_cls=supersmoother.SuperSmoother)
    plt.plot(x, smooth.smooth_result, label='Fast')
    plt.plot(x, y, '.', label='data')
    plt.legend()
    plt.show()
1360800
def _move(self, roll=0, pitch=0, gaz=0, yaw=0):
        '''
        
        '''
        self.send(at.PCMD(at.PCMD.flag.progressive, roll, pitch, gaz, yaw))