本文整理汇总了C++中ObjectType::getCentroid方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectType::getCentroid方法的具体用法?C++ ObjectType::getCentroid怎么用?C++ ObjectType::getCentroid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectType
的用法示例。
在下文中一共展示了ObjectType::getCentroid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: comp
KDTree<ObjectType, FloatType, dimension>::KDTree(vector<ObjectType> objs, unsigned splitDim, size_t minNodeSize) {
this->splitDim = splitDim;
lower = NULL;
upper = NULL;
size_t numObjs = objs.size();
if (numObjs < minNodeSize) {
this->nodeObjects = objs;
} else {
CoordinateComperator comp(splitDim);
sort(objs.begin(), objs.end(), comp);
ObjectType center = objs[numObjs/2];
FloatType splitPlanePos = center.getCentroid()[splitDim];
splitPlaneBoundaryLowerNodeUpperBound = -1E30f;
splitPlaneBoundaryUpperNodeLowerBound = 1E30f;
vector<ObjectType> lowerList;
vector<ObjectType> upperList;
for (size_t i=0; i<numObjs; i++) {
FloatType centroidCoord = objs[i].getCentroid(splitDim);
bool sortIntoUpper = false;
if (centroidCoord >= splitPlanePos) {
sortIntoUpper = true;
}
if (sortIntoUpper) {
upperList.push_back(objs[i]);
splitPlaneBoundaryUpperNodeLowerBound = min(splitPlaneBoundaryUpperNodeLowerBound, objs[i].getMinBB(splitDim));
} else {
lowerList.push_back(objs[i]);
splitPlaneBoundaryLowerNodeUpperBound = max(splitPlaneBoundaryLowerNodeUpperBound, objs[i].getMaxBB(splitDim));
}
}
if (lowerList.size() == objs.size() || upperList.size() == objs.size()) {
this->nodeObjects = objs;
} else {
if (!lowerList.empty()) lower = new KDTree(lowerList, (splitDim+1) % dimension, minNodeSize);
if (!upperList.empty()) upper = new KDTree(upperList, (splitDim+1) % dimension, minNodeSize);
}
}
}