:return: center of mass
961324
def com(self, center1_x, center1_y, center2_x, center2_y, Fm):
        
        com_x = (Fm * center1_x + center2_x)/(Fm + 1.)
        com_y = (Fm * center1_y + center2_y)/(Fm + 1.)
        return com_x, com_y
449585
def centerLatLon(self):
        
        # GET CENTROID FROM GSSHA GRID
        gssha_grid = self.getGrid()

        min_x, max_x, min_y, max_y = gssha_grid.bounds()
        x_ext, y_ext = transform(gssha_grid.proj,
                                 Proj(init='epsg:4326'),
                                 [min_x, max_x, min_x, max_x],
                                 [min_y, max_y, max_y, min_y],
                                 )
        return np.mean(y_ext), np.mean(x_ext)
512107
def centerOfMass(self):
        
        cmf = vtk.vtkCenterOfMass()
        cmf.SetInputData(self.polydata(True))
        cmf.Update()
        c = cmf.GetCenter()
        return np.array(c)
225549
def C(self):
        '''
        
        '''
        return Point(self.maxX, self.maxY, self.origin.z)
858300
def center_end(r, window_size):
  
  res = copy.copy(r)
  res.start = res.end - window_size / 2
  res.end = res.start + window_size
  return res
622276
def get_center(self):
        
        return Point((self.p1.x+self.p2.x)/2.0, (self.p1.y+self.p2.y)/2.0)
1076833
def get_center_of_mass(self):
        
        xsum, ysum, counter = 0., 0., 0
        for stroke in self.get_pointlist():
            for point in stroke:
                xsum += point['x']
                ysum += point['y']
                counter += 1
        return (xsum / counter, ysum / counter)
1160836
def focus0(self):
        '''
        

        '''
        f = Point(self.center)

        if self.xAxisIsMajor:
            f.x -= self.linearEccentricity
        else:
            f.y -= self.linearEccentricity
        return f
697142
def grav_pot(self, x, y, rho0, gamma, center_x=0, center_y=0):
        
        x_ = x - center_x
        y_ = y - center_y
        r = np.sqrt(x_**2 + y_**2)
        mass_3d = self.mass_3d(r, rho0, gamma)
        pot = mass_3d/r
        return pot
1344356
def _get_nsymop(self):
        """"""
        if self.centrosymmetric:
            return 2 * len(self._rotations) * len(self._subtrans)
        else:
            return len(self._rotations) * len(self._subtrans)
632074
def center_of_mass(entity, geometric=False):
    
    
    # Structure, Model, Chain, Residue
    if isinstance(entity, Entity.Entity):
        atom_list = entity.get_atoms()
    # List of Residues, added 2018-03-17 by Nathan
    elif hasattr(entity, '__iter__') and [x for x in entity if x.level == 'R']:
        atom_list = []
        for res in entity:
            atom_list.extend(list(res.get_atoms()))
    # List of Atoms
    elif hasattr(entity, '__iter__') and [x for x in entity if x.level == 'A']:
        atom_list = entity
    else: # Some other weirdo object
        raise ValueError("Center of Mass can only be calculated from the following objects:\n"
                            "Structure, Model, Chain, Residue, list of Atoms.")
    
    masses = []
    positions = [ [], [], [] ] # [ [X1, X2, ..] , [Y1, Y2, ...] , [Z1, Z2, ...] ]
    
    for atom in atom_list:
        masses.append(atom.mass)
        
        for i, coord in enumerate(np.array(atom.coord).tolist()):
            positions[i].append(coord)

    # If there is a single atom with undefined mass complain loudly.
    if 'ukn' in set(masses) and not geometric:
        raise ValueError("Some Atoms don't have an element assigned.\n"
                         "Try adding them manually or calculate the geometrical center of mass instead.")
    
    if geometric:
        return [sum(coord_list)/len(masses) for coord_list in positions]
    else:       
        w_pos = [ [], [], [] ]
        for atom_index, atom_mass in enumerate(masses):
            w_pos[0].append(positions[0][atom_index]*atom_mass)
            w_pos[1].append(positions[1][atom_index]*atom_mass)
            w_pos[2].append(positions[2][atom_index]*atom_mass)

        return [sum(coord_list)/sum(masses) for coord_list in w_pos]
1182592
def getTopRight(self):
        
        return (float(self.get_x()) + float(self.get_width()), float(self.get_y()) + float(self.get_height()))
416296
def center(self, axis=1):
        
        if axis == 1:
            return self.map(lambda x: x - mean(x))
        elif axis == 0:
            meanval = self.mean().toarray()
            return self.map(lambda x: x - meanval)
        else:
            raise Exception('Axis must be 0 or 1')
694847
def getCenter(self):
        '''
        
        '''

        (left, top), (right, bottom) = self.getCoords()
        x = left + (right - left) / 2
        y = top + (bottom - top) / 2
        return (x, y)
718163
private void centerOnCurrentItem() {
        if(!mPieData.isEmpty()) {
            PieModel current = mPieData.get(getCurrentItem());
            int targetAngle;

            if(mOpenClockwise) {
                targetAngle = (mIndicatorAngle - current.getStartAngle()) - ((current.getEndAngle() - current.getStartAngle()) / 2);
                if (targetAngle < 0 && mPieRotation > 0) targetAngle += 360;
            }
            else {
                targetAngle = current.getStartAngle() + (current.getEndAngle() - current.getStartAngle()) / 2;
                targetAngle += mIndicatorAngle;
                if (targetAngle > 270 && mPieRotation < 90) targetAngle -= 360;
            }

            mAutoCenterAnimator.setIntValues(targetAngle);
            mAutoCenterAnimator.setDuration(AUTOCENTER_ANIM_DURATION).start();

        }
    }
586172
def center(self):
        ''''''
        points = np.array(self._points)
        return np.mean(points[:, COLS.XYZ], axis=0)
271304
def get_center_from_json(cls, data):
        
        center_lat = None
        center_lon = None
        center = data.get("center")
        if isinstance(center, dict):
            center_lat = center.get("lat")
            center_lon = center.get("lon")
            if center_lat is None or center_lon is None:
                raise ValueError("Unable to get lat or lon of way center.")
            center_lat = Decimal(center_lat)
            center_lon = Decimal(center_lon)
        return (center_lat, center_lon)