Esempio n. 1
0
/**-------------------------------------------------------------------------------
    build_hull

    Building the hull consists of two procedures: building the lower and
    then the upper hull. The two procedures are nearly identical - the main
    difference between the two is the test for convexity. When building the upper
    hull, our rule is that the middle point must always be *above* the line formed
    by its two closest neighbors. When building the lower hull, the rule is that point
    must be *below* its two closest neighbors. We pass this information to the
    building routine as the last parameter, which is either -1 or 1.

    @brief
    @return std::vector<Ogre::Vector3>
---------------------------------------------------------------------------------*/
std::vector<Ogre::Vector3> ConvexHullGraham::build_hull()
{
	build_half_hull(mLowerPartitionPoints, mLowerHull, 1);
	build_half_hull(mUpperPartitionPoints, mUpperHull, -1);

	std::vector<Ogre::Vector3> ret;

	for (size_t i = 0 ; i < mLowerHull.size() ; i++)
	{
		ret.push_back(mLowerHull[i]);
	}

	for (std::vector<Ogre::Vector3>::reverse_iterator ii = mUpperHull.rbegin() + 1;
	        ii != mUpperHull.rend(); ++ii)
	{
		ret.push_back(*ii);
	}

	return ret;
}
Esempio n. 2
0
//
// Building the hull consists of two procedures: building the lower
// and then the upper hull. The two procedures are nearly identical -
// the main difference between the two is the test for convexity. When
// building the upper hull, our rull is that the middle point must
// always be *above* the line formed by its two closest
// neighbors. When building the lower hull, the rule is that point
// must be *below* its two closest neighbors. We pass this information
// to the building routine as the last parameter, which is either -1
// or 1.
//
void GrahamScan::build_hull()
{
  build_half_hull(lower_partition_points, lower_hull, 1 );
  build_half_hull(upper_partition_points, upper_hull, -1 );
}