Return the slope m of this line segment.
349656
def get_slope(self):
        """"""
        # y1 = m*x1 + t
        # y2 = m*x2 + t => y1-y2 = m*(x1-x2) <=> m = (y1-y2)/(x1-x2)
        return ((self.p1.y-self.p2.y) / (self.p1.x-self.p2.x))
711534
def gradient(self, mu, dist):
        
        return dist.levels/(mu*(dist.levels - mu))
1169254
def intersect (self, line):
     
     eps   = 1e-8
     d     = (line.q - line.p)
     dn    = d.dot(self.n)
     point = None

     if abs(dn) >= eps:
       mu = self.n.dot(self.p - line.p) / dn
       if mu >= 0 and mu <= 1:
         point = line.p + mu * d

     return point
38661
public Direction direction() {
        if (!Op.isFinite(slope) || Op.isEq(slope, 0.0)) {
            return Direction.Zero;
        }
        if (Op.isGt(slope, 0.0)) {
            return Direction.Positive;
        }
        return Direction.Negative;
    }
509696
public FastQueue<LineParametric2D_F32> extractLines() {
		lines.reset();
		foundLines.reset();
		foundIntensity.reset();

		extractor.process(transform, null,null,null, foundLines);

		int w2 = transform.width/2;

		for( int i = 0; i < foundLines.size(); i++ ) {
			Point2D_I16 p = foundLines.get(i);

			float r = (float)(r_max*(p.x-w2)/w2);
			float c = tableTrig.c[p.y];
			float s = tableTrig.s[p.y];

			float x0 = r*c+originX;
			float y0 = r*s+originY;

			foundIntensity.push( transform.get(p.x,p.y));
			LineParametric2D_F32 l = lines.grow();
			l.p.set(x0,y0);
			l.slope.set(-s,c);

			Point2D_F64 p2 = new Point2D_F64(); // todo is this even used?!
			lineToCoordinate(l,p2);
		}

		return lines;
	}
1012862
def linear_variogram_model(m, d):
    """"""
    slope = float(m[0])
    nugget = float(m[1])
    return slope * d + nugget
173147
def normal(self):
        '''
        
        '''

        d = self.B - self.A

        return Line([-d.y, d.x], [d.y, -d.x])
1113791
def m_s(ms2, scale, f, alphasMZ=0.1185, loop=3):
    """
    if scale == 2 and f == 3:
        return ms2  # nothing to do
    _sane(scale, f)
    crd = rundec.CRunDec()
    alphas_2 = alpha_s(2, 3, alphasMZ=alphasMZ, loop=loop)
    if f == 3:
        alphas_scale = alpha_s(scale, f, alphasMZ=alphasMZ, loop=loop)
        return crd.mMS2mMS(ms2, alphas_2, alphas_scale, f, loop)
    elif f == 4:
        crd.nfMmu.Mth = 1.3
        crd.nfMmu.muth = 1.3
        crd.nfMmu.nf = 4
        return crd.mL2mH(ms2, alphas_2, 2, crd.nfMmu, scale, loop)
    elif f == 5:
        mc = 1.3
        crd.nfMmu.Mth = mc
        crd.nfMmu.muth = mc
        crd.nfMmu.nf = 4
        msmc = crd.mL2mH(ms2, alphas_2, 2, crd.nfMmu, mc, loop)
        crd.nfMmu.Mth = 4.8
        crd.nfMmu.muth = 4.8
        crd.nfMmu.nf = 5
        alphas_mc = alpha_s(mc, 4, alphasMZ=alphasMZ, loop=loop)
        return crd.mL2mH(msmc, alphas_mc, mc, crd.nfMmu, scale, loop)
    else:
        raise ValueError("Invalid input: f={}, scale={}".format(f, scale))
606280
def MAU(self):
        ''''''
        if self._MAU is None:
            self._MAU = self.linear_system.M * self.AU
        return self._MAU
1186581
def get_SCAT_box(slope, x_mean, y_mean, beta_threshold = .1):
    
    # if beta_threshold is -999, that means null
    if beta_threshold == -999:
        beta_threshold = .1
    slope_err_threshold = abs(slope) * beta_threshold
    x, y = x_mean, y_mean
    # get lines that pass through mass center, with opposite slope
    slope1 =  slope + (2* slope_err_threshold)
    line1_y_int = y - (slope1 * x)
    line1_x_int = -1 * (old_div(line1_y_int, slope1))
    slope2 = slope - (2 * slope_err_threshold)
    line2_y_int = y - (slope2 * x)
    line2_x_int = -1 * (old_div(line2_y_int, slope2))
        # l1_y_int and l2_x_int form the bottom line of the box
        # l2_y_int and l1_x_int form the top line of the box
#    print "_diagonal line1:", (0, line2_y_int), (line2_x_int, 0), (x, y)
#    print "_diagonal line2:", (0, line1_y_int), (line1_x_int, 0), (x, y)
#    print "_bottom line:", [(0, line1_y_int), (line2_x_int, 0)]
#    print "_top line:", [(0, line2_y_int), (line1_x_int, 0)]
    low_bound = [(0, line1_y_int), (line2_x_int, 0)]
    high_bound = [(0, line2_y_int), (line1_x_int, 0)]
    x_max = high_bound[1][0]#
    y_max = high_bound[0][1]
    # function for low_bound
    low_slope = old_div((low_bound[0][1] - low_bound[1][1]), (low_bound[0][0] - low_bound[1][0])) #
    low_y_int = low_bound[0][1]
    def low_bound(x):
        y = low_slope * x + low_y_int
        return y
    # function for high_bound
    high_slope = old_div((high_bound[0][1] - high_bound[1][1]), (high_bound[0][0] - high_bound[1][0])) # y_0-y_1/x_0-x_1
    high_y_int = high_bound[0][1]
    def high_bound(x):
        y = high_slope * x + high_y_int
        return y
    high_line = [high_y_int, high_slope]
    low_line = [low_y_int, low_slope]
    return low_bound, high_bound, x_max, y_max, low_line, high_line
1203941
def _get_memmap(self):
        """"""

        with open(self.filename) as fp:

            data_dtype = self._get_data_dtype()
            hdr_size = native_header.itemsize

            return np.memmap(fp, dtype=data_dtype,
                             shape=(self.mda['number_of_lines'],),
                             offset=hdr_size, mode="r")
161376
private int getLinearInterpolated(final int currentSamplePos, final int currentTuningPos)
	{
		final long s1 = ((long)sample[currentSamplePos  ])<<Helpers.SAMPLE_SHIFT;
		final long s2 = ((long)sample[currentSamplePos+1])<<Helpers.SAMPLE_SHIFT;
		return (int)((s1 + (((s2-s1)*((long)currentTuningPos))>>Helpers.SHIFT))>>Helpers.SAMPLE_SHIFT);
	}
1306813
def click_estimate_slope():
    

    c1 = _pylab.ginput()
    if len(c1)==0:
        return None

    c2 = _pylab.ginput()
    if len(c2)==0:
        return None

    return (c1[0][1]-c2[0][1])/(c1[0][0]-c2[0][0])
675389
def step(self, x):
        """
        return x - self.coeff_A * self.gradient(x) \
               + self.coeff_B * np.random.normal(size=self.dim)
284425
def _mdens(self,m):
        """"""
        return (self.a/m)**self.alpha/(1.+m/self.a)**(self.betaminusalpha)
430442
def lineOffsetWithMinimumDistanceToPoint(point, line_start, line_end, perpendicular=False):
    """"""
    p = point
    p1 = line_start
    p2 = line_end
    l = distance(p1, p2)
    u = ((p[0] - p1[0]) * (p2[0] - p1[0])) + ((p[1] - p1[1]) * (p2[1] - p1[1]))
    if l == 0 or u < 0.0 or u > l * l:
        if perpendicular:
            return INVALID_DISTANCE
        if u < 0:
            return 0
        return l
    return u / l
87235
def _process(self, segments):
        """"""
        # sort_f= lambda r: max_line_width*(r[1]/max_line_height)+r[0]
        # segments= sorted(segments, key=sort_f)
        # segments= segments_to_numpy( segments )
        # return segments
        mlh, mlw = self.max_line_height, self.max_line_width
        s = segments.astype(numpy.uint32)  # prevent overflows
        order = mlw * (s[:, 1] // mlh) + s[:, 0]
        sort_order = numpy.argsort(order)
        return segments[sort_order]