Return the center of a bounding box defined by a box plot.
        Draws a box plot on self.svg.
549217
def _draw_box(self, parent_node, quartiles, outliers, box_index, metadata):
        
        width = (self.view.x(1) - self.view.x(0)) / self._order
        series_margin = width * self._series_margin
        left_edge = self.view.x(0) + width * box_index + series_margin
        width -= 2 * series_margin

        # draw lines for whiskers - bottom, median, and top
        for i, whisker in enumerate((quartiles[0], quartiles[2],
                                     quartiles[4])):
            whisker_width = width if i == 1 else width / 2
            shift = (width - whisker_width) / 2
            xs = left_edge + shift
            xe = left_edge + width - shift
            alter(
                self.svg.line(
                    parent_node,
                    coords=[(xs, self.view.y(whisker)),
                            (xe, self.view.y(whisker))],
                    class_='reactive tooltip-trigger',
                    attrib={'stroke-width': 3}
                ), metadata
            )

        # draw lines connecting whiskers to box (Q1 and Q3)
        alter(
            self.svg.line(
                parent_node,
                coords=[(left_edge + width / 2, self.view.y(quartiles[0])),
                        (left_edge + width / 2, self.view.y(quartiles[1]))],
                class_='reactive tooltip-trigger',
                attrib={'stroke-width': 2}
            ), metadata
        )
        alter(
            self.svg.line(
                parent_node,
                coords=[(left_edge + width / 2, self.view.y(quartiles[4])),
                        (left_edge + width / 2, self.view.y(quartiles[3]))],
                class_='reactive tooltip-trigger',
                attrib={'stroke-width': 2}
            ), metadata
        )

        # box, bounded by Q1 and Q3
        alter(
            self.svg.node(
                parent_node,
                tag='rect',
                x=left_edge,
                y=self.view.y(quartiles[1]),
                height=self.view.y(quartiles[3]) - self.view.y(quartiles[1]),
                width=width,
                class_='subtle-fill reactive tooltip-trigger'
            ), metadata
        )

        # draw outliers
        for o in outliers:
            alter(
                self.svg.node(
                    parent_node,
                    tag='circle',
                    cx=left_edge + width / 2,
                    cy=self.view.y(o),
                    r=3,
                    class_='subtle-fill reactive tooltip-trigger'
                ), metadata
            )

        return (
            left_edge + width / 2,
            self.view.y(sum(quartiles) / len(quartiles))
        )
843604
function (center, zoom, bounds) {

		if (!bounds) { return center; }

		var centerPoint = this.project(center, zoom),
		    viewHalf = this.getSize().divideBy(2),
		    viewBounds = new L.Bounds(centerPoint.subtract(viewHalf), centerPoint.add(viewHalf)),
		    offset = this._getBoundsOffset(viewBounds, bounds, zoom);

		// If offset is less than a pixel, ignore.
		// This prevents unstable projections from getting into
		// an infinite loop of tiny offsets.
		if (offset.round().equals([0, 0])) {
			return center;
		}

		return this.unproject(centerPoint.add(offset), zoom);
	}
236855
function _getBoundingBox (feature) {
  if (!feature.bbox) {
    return;
  }
  return {
    south: feature.bbox[0],
    west: feature.bbox[1],
    north: feature.bbox[2],
    east: feature.bbox[3]
  };
}
884412
def comp_centroid(data, bounding_box, debug_plot=False, plot_reference=None, logger=None):
    """"""

    from matplotlib.patches import Ellipse

    if logger is None:
        logger = logging.getLogger(__name__)

    region = bounding_box.slice
    ref_x = region[1].start
    ref_y = region[0].start
    logger.debug('region ofset is %s, %s', ref_x, ref_y)
    subimage = data[region].copy()
    bkg = sep.Background(subimage)
    data_sub = subimage - bkg
    objects = sep.extract(data_sub, 1.5, err=bkg.globalrms)
    # Select brightest object
    logger.debug('%d object found', len(objects))

    if len(objects) == 0:
        # print('No objects')
        return None

    iadx = objects['flux'].argmax()
    # plot background-subtracted image
    maxflux = objects[iadx]

    if debug_plot:
        fig, ax = plt.subplots()
        m, s = np.mean(data_sub), np.std(data_sub)
        ax.imshow(data_sub, interpolation='nearest', cmap='gray',
                  vmin=m - s, vmax=m + s, origin='lower',
                  extent=bounding_box.extent)
        if plot_reference:
            e = Ellipse(xy=(plot_reference[0], plot_reference[1]),
                        width=6,
                        height=6,
                        angle=0)
            e.set_facecolor('none')
            e.set_edgecolor('green')
            ax.add_artist(e)

        # plot an ellipse for each object
        for idx, obj in enumerate(objects):
            e = Ellipse(xy=(obj['x'] + ref_x, obj['y'] + ref_y),
                        width=6 * obj['a'],
                        height=6 * obj['b'],
                        angle=obj['theta'] * 180. / np.pi)
            e.set_facecolor('none')
            if idx == iadx:
                e.set_edgecolor('blue')
            else:
                e.set_edgecolor('red')
            ax.add_artist(e)
        return maxflux['x'], maxflux['y'], ax
    else:
        return maxflux['x'], maxflux['y']
182334
function _drawBoundingBox(min, max, color) {
        var p = new Primitive();
        p.color = toColor(color);

        var halfExtents = new THREE.Vector3();
        halfExtents.subVectors(max, min);
        halfExtents.multiplyScalar(0.5);
        var center = new THREE.Vector3();
        center.addVectors(max, min);
        center.multiplyScalar(0.5);

        var edgeCoord = [1, 1, 1];

        for (var i = 0; i < 4; i++) {
            for (var j = 0; j < 3; j++) {
                var pa = new THREE.Vector3(
                    edgeCoord[0] * halfExtents.x,
                    edgeCoord[1] * halfExtents.y,
                    edgeCoord[2] * halfExtents.z);
                pa.add(center);

                var otherCoord = j % 3;
                edgeCoord[otherCoord] = edgeCoord[otherCoord] * -1;
                var pb = new THREE.Vector3(
                    edgeCoord[0] * halfExtents.x,
                    edgeCoord[1] * halfExtents.y,
                    edgeCoord[2] * halfExtents.z);
                pb.add(center);

                p.vertices.push(pa, pb);
            }

            edgeCoord = [-1, -1, -1];

            if (i < 3) {
                edgeCoord[i] = edgeCoord[i] * -1;
            }
        }

        renderer.addPrimitive(p);
    }
821190
def centroid(X):
    
    C = np.sum(X, axis=0) / len(X)
    return C
458255
function centerInlineLegendOnSVG() {
            let legendGroupSize = svg.select('g.legend-container-group').node().getBoundingClientRect().width + getLineElementMargin();
            let emptySpace = width - legendGroupSize;
            let newXPosition = (emptySpace/2);

            if (emptySpace > 0) {
                svg.select('g.legend-container-group')
                    .attr('transform', `translate(${newXPosition},0)`)
            }
        }
307821
function centerMesh (mesh) {
  var bb = boundingBox(mesh.positions)

  var _translate = [
    -0.5 * (bb[0][0] + bb[1][0]),
    -0.5 * (bb[0][1] + bb[1][1]),
    -0.5 * (bb[0][2] + bb[1][2])
  ]
  var translate = mat4.create()
  mat4.translate(translate, translate, _translate)
  mesh.positions = tform(mesh.positions, translate)
}
466188
function() {
			
            var point = svg.createSVGPoint();
            point.x = this.x;
            point.y = this.y;
			
            return point;
        }
891490
def bounding_box(self):
        

        w2 = self.width / 2.
        h2 = self.height / 2.
        cos_angle = np.cos(self.angle)    # self.angle is a Quantity
        sin_angle = np.sin(self.angle)    # self.angle is a Quantity
        dx1 = abs(w2 * cos_angle - h2 * sin_angle)
        dy1 = abs(w2 * sin_angle + h2 * cos_angle)
        dx2 = abs(w2 * cos_angle + h2 * sin_angle)
        dy2 = abs(w2 * sin_angle - h2 * cos_angle)
        dx = max(dx1, dx2)
        dy = max(dy1, dy2)

        xmin = self.center.x - dx
        xmax = self.center.x + dx
        ymin = self.center.y - dy
        ymax = self.center.y + dy

        return BoundingBox.from_float(xmin, xmax, ymin, ymax)
701611
def get_bounding_box(self):
        
        if not isinstance(self.ref_cell, Cell):
            return None
        if (self.rotation is None and self.magnification is None and
                self.x_reflection is None):
            key = self
        else:
            key = (self.ref_cell, self.rotation, self.magnification,
                   self.x_reflection)
        deps = self.ref_cell.get_dependencies(True)
        if not (self.ref_cell._bb_valid and
                all(ref._bb_valid for ref in deps) and key in _bounding_boxes):
            for ref in deps:
                ref.get_bounding_box()
            self.ref_cell.get_bounding_box()
            tmp = self.origin
            self.origin = None
            polygons = self.get_polygons()
            self.origin = tmp
            if len(polygons) == 0:
                bb = None
            else:
                all_points = numpy.concatenate(polygons).transpose()
                bb = numpy.array(((all_points[0].min(), all_points[1].min()),
                                  (all_points[0].max(), all_points[1].max())))
            _bounding_boxes[key] = bb
        else:
            bb = _bounding_boxes[key]
        if self.origin is None or bb is None:
            return bb
        else:
            return bb + numpy.array(((self.origin[0], self.origin[1]),
                                     (self.origin[0], self.origin[1])))
538666
def arc(document, bounding_rect, start, extent, style):
	""
	(x1, y1, x2, y2) = bounding_rect
	import math
	
	cx = (x1 + x2)/2.0
	cy = (y1 + y2)/2.0

	rx = (x2 - x1)/2.0
	ry = (y2 - y1)/2.0
	
	start  = math.radians(float(start))
	extent = math.radians(float(extent))

	# from SVG spec:
	# http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
	x1 =  rx * math.cos(start) + cx
	y1 = -ry * math.sin(start) + cy # XXX: ry is negated here

	x2 =  rx * math.cos(start + extent) + cx
	y2 = -ry * math.sin(start + extent) + cy # XXX: ry is negated here

	if abs(extent) > math.pi:
		fa = 1
	else:
		fa = 0

	if extent > 0.0:
		fs = 0
	else:
		fs = 1
	
	path = []
	# common: arc
	path.append('M%s,%s' % (x1, y1))
	path.append('A%s,%s 0 %d %d %s,%s' % (rx, ry, fa, fs, x2, y2))
	
	if style == ARC:
		pass
	
	elif style == CHORD:
		path.append('z')

	else: # default: pieslice
		path.append('L%s,%s' % (cx, cy))
		path.append('z')

	return setattribs(document.createElement('path'), d = ''.join(path))
1219742
def centerOn(self, point):
        
        rect = self.rect()
        x = point.x() - rect.width() / 2.0
        y = point.y() - rect.height() / 2.0
        
        self.setPos(x, y)
263592
def moments_central(self):
        

        ycentroid, xcentroid = self.cutout_centroid.value
        return _moments_central(self._filtered_data_zeroed,
                                center=(xcentroid, ycentroid), order=3)
27294
def boundingbox(self):
        
        xyz = self.xyz
        return Box(mins=xyz.min(axis=0), maxs=xyz.max(axis=0))
127936
def bbox_vert_aligned_center(box1, box2):
    
    if not (box1 and box2):
        return False
    return abs(((box1.right + box1.left) / 2.0) - ((box2.right + box2.left) / 2.0)) <= 5
1361570
def center(self):
        

        if np.all(np.isfinite(self.xyz)):
            return np.mean(self.xyz, axis=0)