Given a bbox that contains a given point, return the (x, y) displacement
    necessary to make the bbox not overlap the point.
3799
def overlap_bbox_and_point(bbox, xp, yp):
    """"""
    cx, cy = get_midpoint(bbox)

    dir_x = np.sign(cx-xp)
    dir_y = np.sign(cy-yp)

    if dir_x == -1:
        dx = xp - bbox.xmax
    elif dir_x == 1:
        dx = xp - bbox.xmin
    else:
        dx = 0

    if dir_y == -1:
        dy = yp - bbox.ymax
    elif dir_y == 1:
        dy = yp - bbox.ymin
    else:
        dy = 0
    return dx, dy
864776
static Point calculateCenterOfBoundingBox(Point[] coordinates) {
        double pointXMin = coordinates[0].x;
        double pointXMax = coordinates[0].x;
        double pointYMin = coordinates[0].y;
        double pointYMax = coordinates[0].y;

        for (Point immutablePoint : coordinates) {
            if (immutablePoint.x < pointXMin) {
                pointXMin = immutablePoint.x;
            } else if (immutablePoint.x > pointXMax) {
                pointXMax = immutablePoint.x;
            }

            if (immutablePoint.y < pointYMin) {
                pointYMin = immutablePoint.y;
            } else if (immutablePoint.y > pointYMax) {
                pointYMax = immutablePoint.y;
            }
        }

        return new Point((pointXMin + pointXMax) / 2, (pointYMax + pointYMin) / 2);
    }
914238
def move(self, point, reverse=False):
        
        if reverse:
            point = [-1 * i for i in point]
        return Box(self.x + point[0], self.y + point[1], self.width, self.height)
167466
def collide_point(self, x, y):
        
        if not self.collider:
            return False
        return (x, y) in self.collider
1295574
def Minus(self, other):
    
    return Point(self.x - other.x,
                 self.y - other.y,
                 self.z - other.z)
641418
function closePoint(px, py, ax, ay, bx, by, r) {

    var x = ax,
        y = ay,
        dx = bx - x,
        dy = by - y;

    if (dx !== 0 || dy !== 0) {

        var t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);

        if (t >= 1) {
            x = bx;
            y = by;
            t = 1;

        } else if (t > 0) {
            x += dx * t;
            y += dy * t;

        } else {
            t = 0;
        }
    }

    dx = px - x;
    dy = py - y;

    return dx * dx + dy * dy < r * r ? t : null;
}
978954
def _within_box(points, boxes):
    
    x_within = (points[..., 0] >= boxes[:, 0, None]) & (
        points[..., 0] <= boxes[:, 2, None]
    )
    y_within = (points[..., 1] >= boxes[:, 1, None]) & (
        points[..., 1] <= boxes[:, 3, None]
    )
    return x_within & y_within
1007391
function(bbox) {
        var coords = this._toIndexKey(bbox);
        var array = this._rtree.search(coords);
        array = this._sortByDistance(array, bbox);
        var result = [];
        var filterMultiPoints = !!this.options.filterPoints;
        for (var i = 0; i < array.length; i++) {
            var arr = array[i];
            var r = arr.data;
            var geometry = this.getGeometry(r);
            var handled = false;
            GeoJsonUtils.forEachGeometry(geometry, {
                onPoints : function(points) {
                    if (!handled
                            && (!filterMultiPoints || GeometryUtils
                                    .bboxContainsPoints(points, bbox))) {
                        result.push(r);
                        handled = true;
                    }
                },
                onLines : function(lines) {
                    if (!handled
                            && GeometryUtils.bboxIntersectsLines(lines, bbox)) {
                        result.push(r);
                        handled = true;
                    }
                },
                onPolygons : function(polygons) {
                    if (!handled
                            && GeometryUtils.bboxIntersectsPolygonsWithHoles(
                                    polygons, bbox)) {
                        result.push(r);
                        handled = true;
                    }
                }
            });
        }
        return result;
    }
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;
        }
    }
559642
def move(self, x, y):
        
        self._cursor = self._normalizePoint(x, y)
230215
function (point) {
        var rect = this.getRect();
        var axis = this.getAxis();
        var orient = axis.orient;
        if (orient === 'horizontal') {
            return axis.contain(axis.toLocalCoord(point[0]))
            && (point[1] >= rect.y && point[1] <= (rect.y + rect.height));
        }
        else {
            return axis.contain(axis.toLocalCoord(point[1]))
            && (point[0] >= rect.y && point[0] <= (rect.y + rect.height));
        }
    }
434024
def _call(self, x):
        """"""
        # TODO: update when integration operator is in place: issue #440
        pointwise_norm = self.pointwise_norm(x)
        return pointwise_norm.inner(pointwise_norm.space.one())
183470
def point_displ(pt1, pt2):
    

    #Imports
    import numpy as np

    # Make iterable
    if not np.iterable(pt1):
        pt1 = np.float64(np.array([pt1]))
    else:
        pt1 = np.float64(np.array(pt1).squeeze())
    ## end if
    if not np.iterable(pt2):
        pt2 = np.float64(np.array([pt2]))
    else:
        pt2 = np.float64(np.array(pt2).squeeze())
    ## end if

    # Calculate the displacement vector and return
    displ = np.matrix(np.subtract(pt2, pt1)).reshape(3,1)
    return displ
724777
def bbox(self):
        """"""
        bbs = [seg.bbox() for seg in self._segments]
        xmins, xmaxs, ymins, ymaxs = list(zip(*bbs))
        xmin = min(xmins)
        xmax = max(xmaxs)
        ymin = min(ymins)
        ymax = max(ymaxs)
        return xmin, xmax, ymin, ymax
930426
def Plus(self, other):
    
    return Point(self.x + other.x,
                 self.y + other.y,
                 self.z + other.z)
1136178
def displace(self, vector):
        
        self._bottom += vector.y
        self._left += vector.x
        return self
157852
def bbox(self):
        """"""
        if not hasattr(self, '_bbox'):
            if self.has_pixels():
                self._bbox = (
                    self._record.left,
                    self._record.top,
                    self._record.right,
                    self._record.bottom,
                )
            elif self.has_origination() and not any(
                x.invalidated for x in self.origination
            ):
                lefts, tops, rights, bottoms = zip(*[
                    x.bbox for x in self.origination
                ])
                self._bbox = (
                    int(min(lefts)), int(min(tops)),
                    int(max(rights)), int(max(bottoms))
                )
            elif self.has_vector_mask():
                bbox = self.vector_mask.bbox
                self._bbox = (
                    int(bbox[0] * self._psd.width),
                    int(bbox[1] * self._psd.height),
                    int(bbox[2] * self._psd.width),
                    int(bbox[3] * self._psd.height),
                )
            else:
                self._bbox = (0, 0, 0, 0)
        return self._bbox