Given x1, x2, a, b, where:

        x1 - x0         x3 - x2
    a = ------- ,   b = -------
        x3 - x0         x3 - x0

    determine the points x0 and x3:

    x0         x1                x2       x3
    |----------|-----------------|--------|
164702
def _limits_helper(x1, x2, a, b, snap=False):
    
    if x2 < x1:
        raise ValueError("x2 < x1")
    if a + b >= 1:
        raise ValueError("a + b >= 1")
    if a < 0:
        raise ValueError("a < 0")
    if b < 0:
        raise ValueError("b < 0")
    if snap:
        if x1 >= 0:
            x1 = 0
            a = 0
        elif x2 <= 0:
            x2 = 0
            b = 0
        if x1 == x2 == 0:
            # garbage in garbage out
            return 0., 1.
    elif x1 == x2:
        # garbage in garbage out
        return x1 - 1., x1 + 1.
    if a == 0 and b == 0:
        return x1, x2
    elif a == 0:
        return x1, (x2 - b * x1) / (1 - b)
    elif b == 0:
        return (x1 - a * x2) / (1 - a), x2
    x0 = ((b / a) * x1 + x2 - (x2 - x1) / (1 - a - b)) / (1 + b / a)
    x3 = (x2 - x1) / (1 - a - b) + x0
    return x0, x3
602365
function (a, b) {                                                               // 504
  a = pointToArray(a);                                                                                        // 505
  b = pointToArray(b);                                                                                        // 506
  var x = a[0] - b[0];                                                                                        // 507
  var y = a[1] - b[1];                                                                                        // 508
  if (_.isNaN(x) || _.isNaN(y))                                                                               // 509
    return null;                                                                                              // 510
  return Math.sqrt(x * x + y * y);                                                                            // 511
}
303754
public static float pointLineDistSq (float px, float py,
                                         float x1, float y1, float x2, float y2) {
        x2 -= x1;
        y2 -= y1;
        px -= x1;
        py -= y1;
        float s = px * y2 - py * x2;
        return (s * s) / (x2 * x2 + y2 * y2);
    }
1374171
def line(p1, p2):
    
    A = (p1[1] - p2[1])
    B = (p2[0] - p1[0])
    C = (p1[0]*p2[1] - p2[0]*p1[1])
    return A, B, -C
537715
def _quadPoints(size, disp1, disp2):
        """"""
        w, h = size
        x1, y1 = disp1
        x2, y2 = disp2

        return (
            x1,    -y1,
            -x1,    h + y2,
            w + x2, h - y2,
            w - x2, y1
        )
1208629
def contains_point(self, x, y):
        
        if x is None and y is None:
            return True
        return (y * y - (x * x * x + self._a * x + self._b)) % self._p == 0
1222387
def contains(self, point):
        

        y2 = point.y * point.y
        x3 = point.x * point.x * point.x
        return (y2 - (x3 + self.a * point.x + self.b)) % self.p == 0
568291
function solveAngle(a, b, c) {
    var temp = (a * a + b * b - c * c) / (2 * a * b);
    if (temp >= -1 && temp <= 1) {
        return radToDeg(Math.acos(temp));
    }
    else {
        throw new Error("No angle solution for points " + a + " " + b + " " + c);
    }
}
979878
function (point1, point2, y) {
  let f1 = y - point1[1]
  let f2 = point2[1] - point1[1]
  if (f2 < 0) {
    f1 = -f1
    f2 = -f2
  }
  let t
  if (f1 <= 0) {
    t = 0.0
  } else if (f1 >= f2) {
    t = 1.0
  } else if (f2 < 1e-10) { // FIXME Should this be CSG.EPS?
    t = 0.5
  } else {
    t = f1 / f2
  }
  let result = point1[0] + t * (point2[0] - point1[0])
  return result
}
1344565
private function _theta(PointInterface $a, PointInterface $b)
    {
        list($x1, $y1) = $a->getCoordinates();
        list($x2, $y2) = $b->getCoordinates();
        return atan2($y2-$y1, $x2 - $x1) + 2 * M_PI;
    }
102896
function ( vectorA, vectorB, vectorC ) {

		var a, b, c,
			point = new THREE.Vector3(),
			tmp = THREE.GeometryUtils.__v1;

		a = THREE.GeometryUtils.random();
		b = THREE.GeometryUtils.random();

		if ( ( a + b ) > 1 ) {

			a = 1 - a;
			b = 1 - b;

		}

		c = 1 - a - b;

		point.copy( vectorA );
		point.multiplyScalar( a );

		tmp.copy( vectorB );
		tmp.multiplyScalar( b );

		point.addSelf( tmp );

		tmp.copy( vectorC );
		tmp.multiplyScalar( c );

		point.addSelf( tmp );

		return point;

	}
1371554
function (a, b) {
            if (!b.pos || !a.pos) {
                return (a.pos ? -Infinity : Infinity);
            }
            var result = b.pos.z - a.pos.z;
            return (result ? result : (b.pos.y - a.pos.y));
        }
465075
def point(self, pos):
        """"""
        return ((1 - pos) ** 3 * self.start) + \
               (3 * (1 - pos) ** 2 * pos * self.control1) + \
               (3 * (1 - pos) * pos ** 2 * self.control2) + \
               (pos ** 3 * self.end)
1322398
def Bx(self):        
        
        #  0         self.b3  -self.b2
        # -self.b3   0         self.b1
        #  self.b2  -self.b1   0
        
        
        m = np.zeros((len(self.b1), 3, 3))
        m[:, 0, 1] = +self.b3
        m[:, 0, 2] = -self.b2
        m[:, 1, 0] = -self.b3
        m[:, 1, 2] = +self.b1
        m[:, 2, 0] = +self.b2
        m[:, 2, 1] = -self.b1
        return m
84817
def find_by_x_and_y(x, y)
      select { |square| square.x == x && square.y == y }.first
    end
259218
function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
  var x01 = x0 - x1,
      y01 = y0 - y1,
      lo = (cw ? rc : -rc) / sqrt(x01 * x01 + y01 * y01),
      ox = lo * y01,
      oy = -lo * x01,
      x11 = x0 + ox,
      y11 = y0 + oy,
      x10 = x1 + ox,
      y10 = y1 + oy,
      x00 = (x11 + x10) / 2,
      y00 = (y11 + y10) / 2,
      dx = x10 - x11,
      dy = y10 - y11,
      d2 = dx * dx + dy * dy,
      r = r1 - rc,
      D = x11 * y10 - x10 * y11,
      d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D * D)),
      cx0 = (D * dy - dx * d) / d2,
      cy0 = (-D * dx - dy * d) / d2,
      cx1 = (D * dy + dx * d) / d2,
      cy1 = (-D * dx + dy * d) / d2,
      dx0 = cx0 - x00,
      dy0 = cy0 - y00,
      dx1 = cx1 - x00,
      dy1 = cy1 - y00;

  // Pick the closer of the two intersection points.
  // TODO Is there a faster way to determine which intersection to use?
  if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) { cx0 = cx1, cy0 = cy1; }

  return {
    cx: cx0,
    cy: cy0,
    x01: -ox,
    y01: -oy,
    x11: cx0 * (r1 / r - 1),
    y11: cy0 * (r1 / r - 1)
  };
}
75140
function(point, bbox) {
        return inRange(point[0], bbox[0][0], bbox[1][0])
                && inRange(point[1], bbox[0][1], bbox[1][1]);
        function inRange(val, a, b) {
            return (val - a) * (val - b) <= 0;
        }
    }