CappedZEllipsoid::CappedZEllipsoid(const Region3D& region, float z_ratio) : m_ellipsoid(Ellipsoid(region)), m_z_cap(region.z_min + (region.z_max - region.z_min)*z_ratio) { if ((z_ratio < 0.0f) || (z_ratio > 1.0f)) { throw std::runtime_error("z-ratio must be in [0.0, 1.0]"); } }
void MultiEllipsoidSampler::computeEllipsoids(RefArrayXXd const totalSample, const unsigned int Nclusters, const vector<int> &clusterIndices, const vector<int> &clusterSizes) { assert(totalSample.cols() == clusterIndices.size()); assert(totalSample.cols() >= Ndimensions + 1); // At least Ndimensions + 1 points are required to start. // Compute "sorted indices" such that clusterIndices[sortedindices[k]] <= clusterIndices[sortedIndices[k+1]] vector<int> sortedIndices = Functions::argsort(clusterIndices); // beginIndex will take values such that the indices for one particular cluster (# n) will be in // sortedIndex[beginIndex, ..., beginIndex + clusterSize[n] - 1] int beginIndex = 0; // Clear whatever was in the ellipsoids collection ellipsoids.clear(); // Create an Ellipsoid for each cluster (provided it's large enough) for (int i = 0; i < Nclusters; i++) { // Skip cluster if number of points is not large enough if (clusterSizes[i] < Ndimensions + 1) { // Move the beginIndex up to the next cluster beginIndex += clusterSizes[i]; // Continue with the next cluster continue; } else { // The cluster is indeed large enough to compute an Ellipsoid. // Copy those points that belong to the current cluster in a separate Array // This is because Ellipsoid needs a contiguous array of points. ArrayXXd sampleOfOneCluster(Ndimensions, clusterSizes[i]); for (int n = 0; n < clusterSizes[i]; ++n) { sampleOfOneCluster.col(n) = totalSample.col(sortedIndices[beginIndex+n]); } // Move the beginIndex up to the next cluster beginIndex += clusterSizes[i]; // Compute the new enlargement fraction (it is the fraction by which each axis of an ellipsoid is enlarged). // This allows for improving the efficiency of the sampling by increasing the chance of having more // points of the cluster falling inside the bounding ellipsoid. double enlargementFraction = updateEnlargementFraction(clusterSizes[i]); // Add ellipsoid at the end of our vector ellipsoids.push_back(Ellipsoid(sampleOfOneCluster, enlargementFraction)); } } Nellipsoids = ellipsoids.size(); }
Ellipsoid::Ellipsoid( double rxy, double rz, int sl, int st ) { Ellipsoid( rxy, rxy, rz, sl, st ); }
Ellipsoid Ellipsoid::GetTranslated(const NX::vector<float, 3> &T) const{ return Ellipsoid(*this).Translate(T); }
Ellipsoid Ellipsoid::GetTransformed(const NX::Matrix<float, 4, 4> &M) const{ return Ellipsoid(*this).Transform(M); }
Ellipsoid Ellipsoid::GetTransformed(const NX::vector<float, 3> &T, const NX::Matrix<float, 3, 3> &R) const{ return Ellipsoid(*this).Transform(T, R); }