void region_momentsOLD(region_info_t *region_info, int n_regions, int *regionMap, int xlen, int ylen, int minNbPix) { int i,j,k; int *imagpntr; region_info_t *infopntr; for (i=0; i < n_regions; i++) { region_center(®ion_info[i]); } /* Ueber das Bild laufen und aus Punkten mit Hilfe der Schwerpunkte Momente berechnen */ for (i=0, imagpntr = regionMap; i<ylen; ++i) { for (k=0; k<xlen; ++k, ++imagpntr) { if (*imagpntr < 0) continue; infopntr = &(region_info[*imagpntr]); if (infopntr->pixelcount > minNbPix) { infopntr->m02 += (i - infopntr->center_y) * (i - infopntr->center_y); infopntr->m20 += (k - infopntr->center_x) * (k - infopntr->center_x); infopntr->m11 += (k - infopntr->center_x) * (i - infopntr->center_y); } } } }
bool WorldCrop::isRegionContained(const mc::RegionPos& region) const { if (type == RECTANGULAR) { // rectangular crop: // just check if the region is contained in the calculated bounds return bounds_region_x.contains(region.x) && bounds_region_z.contains(region.z); } else if (type == CIRCULAR) { // circular crop: // check roughly whether at least one block of the region is included // use the midpoint of the region and determine the distance to the center BlockPos region_center(region.x * 512 + 256, region.z * 512 + 256, 0); int dx = region_center.x - center.x; int dz = region_center.z - center.z; // and check whether it is at most radius + size of a region blocks away return (radius+512)*(radius+512) >= dx*dx + dz*dz; } return true; }