void PolygonObstacle::draw()
{

	Util::Point height_dist(0.0,1.0,0.0);
	for (size_t _vert=0; _vert < this->_points.size()-1; _vert++)
	{
		Util::Point p0, p1;
		p0 = this->_points.at(_vert);
		p1 = this->_points.at(_vert+1);
		Util::DrawLib::drawLine(p0, p1, Util::gBlack, 2.0);
		Util::DrawLib::drawLine(p0+height_dist, p1+height_dist, Util::gBlack, 2.0);
		Util::DrawLib::drawLine(p0, p0+height_dist, Util::gBlack, 2.0);
		Util::DrawLib::drawQuad(p0, p1,	p1 + height_dist, p0 +height_dist,Util::gDarkMagenta);

	}


	if ( isConvex_ )
	{
		Util::Point p0, p1;
		p0 = this->_points.at(this->_points.size()-1);
		p1 = this->_points.at(0);
		Util::DrawLib::drawLine(p0, p1, Util::gBlack, 2.0);
		Util::DrawLib::drawLine(p0+height_dist, p1+height_dist, Util::gBlack, 2.0);
		Util::DrawLib::drawLine(p0, p0+height_dist, Util::gBlack, 2.0);
		Util::DrawLib::drawQuad(p0, p1,	p1 + height_dist, p0 +height_dist, Util::gDarkMagenta);
	}

}
Exemple #2
0
 void operator()( Tree& tree ) const
 {
     std::uniform_int_distribution< size_t > height_dist( m_min_height , m_max_height );
     std::discrete_distribution< int > method_dist { m_grow_prob , 1.0 - m_grow_prob };
     
     size_t height = height_dist( m_rng );
     int method = method_dist( m_rng );
     
     if( method == 0 ) // grow method
     {
         auto generate = make_basic_generate_strategy( m_rng , m_gen , 1 , height );
         generate( tree );
     }
     else // full method
     {
         auto generate = make_basic_generate_strategy( m_rng , m_gen , height - 1 , height );
         generate( tree );
     }
     
 }
int height_dist(const node<P> top_node,v_array<int> &heights)
{
	if (top_node.num_children == 0)
	{
		add_height(0,heights);
		return 0;
	}
	else
	{
		int max_v=0;
		for (int i = 0; i<top_node.num_children ;i++)
		{
			int d = height_dist(top_node.children[i], heights);
			if (d > max_v)
				max_v = d;
		}
		add_height(1 + max_v, heights);
		return (1 + max_v);
	}
}