Foros: ヘルプ (Thread #37324)

VoronoiDiagram point compute probleam ? (2015-11-29 19:49 by Deng Yong #77269)

In agent2D3.1.1 , I use base Interface too compute VoronoiDiagram point,
for exeample
:{
VoronoiDiagram M_pass_voronoi_diagram;

const Rect2D rect = Rect2D::from_center( 0.0, 0.0,
ServerParam::i().pitchLength() - 10.0,
ServerParam::i().pitchWidth() - 10.0 );


M_pass_voronoi_diagram.clear();

const SideID our = wm.ourSide();


const AbstractPlayerCont::const_iterator end = wm.allPlayers().end();
for ( AbstractPlayerCont::const_iterator p = wm.allPlayers().begin();
p != end;
++p )
{

if ( (*p)->side()!=wm.ourSide())
{
M_pass_voronoi_diagram.addPoint( (*p)->pos() );
}

}
// our goal
M_pass_voronoi_diagram.addPoint( Vector2D( - ServerParam::i().pitchHalfLength() + 5.5, 0.0 ) );
// M_pass_voronoi_diagram.addPoint( Vector2D( - ServerParam::i().pitchHalfLength() + 5.5,
// - ServerParam::i().goalHalfWidth() ) );
// M_pass_voronoi_diagram.addPoint( Vector2D( - ServerParam::i().pitchHalfLength() + 5.5,
// + ServerParam::i().goalHalfWidth() ) );

// opponent side corners
M_pass_voronoi_diagram.addPoint( Vector2D( + ServerParam::i().pitchHalfLength() + 10.0,
- ServerParam::i().pitchHalfWidth() - 10.0 ) );
M_pass_voronoi_diagram.addPoint( Vector2D( + ServerParam::i().pitchHalfLength() + 10.0,
+ ServerParam::i().pitchHalfWidth() + 10.0 ) );

M_pass_voronoi_diagram.setBoundingRect( rect );


#if 0
// our goal
M_pass_voronoi_diagram.addPoint( Vector2D( - ServerParam::i().pitchHalfLength() + 5.5, 0.0 ) );
// M_pass_voronoi_diagram.addPoint( Vector2D( - ServerParam::i().pitchHalfLength() + 5.5,
// - ServerParam::i().goalHalfWidth() ) );
// M_pass_voronoi_diagram.addPoint( Vector2D( - ServerParam::i().pitchHalfLength() + 5.5,
// + ServerParam::i().goalHalfWidth() ) );

// opponent side corners
M_pass_voronoi_diagram.addPoint( Vector2D( + ServerParam::i().pitchHalfLength() + 10.0,
- ServerParam::i().pitchHalfWidth() - 10.0 ) );
M_pass_voronoi_diagram.addPoint( Vector2D( + ServerParam::i().pitchHalfLength() + 10.0,
+ ServerParam::i().pitchHalfWidth() + 10.0 ) );

M_pass_voronoi_diagram.setBoundingRect( rect );
#endif

M_pass_voronoi_diagram.compute();


std::vector<Vector2D> *target_map=new std::vector<Vector2D>;
// M_pass_voronoi_diagram.getPointsOnSegments(3,3,target_map);;
double best_eva=0;
Vector2D best_point=target_point;
// std::cout<<(*target_map).size()<<std::endl;

VoronoiDiagram::Vector2DCont VN_Point;
VN_Point=M_pass_voronoi_diagram.resultPoints();
std::ofstream fout("vorongraph.txt",std::ios::app);

for (VoronoiDiagram::Vector2DCont ::const_iterator it =VN_Point.begin(); it!=VN_Point.end(); it++)
{

fout<<"clycle"<<wm.time().cycle()<<"*******"<<(*it)<<std::endl;

if ( (*it).absX()>52||(*it).absY()>33)
{
continue;
}

target_map->push_back((*it));

}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

but I find the point diffrent with soccerwindow2 _voronoi_diagram point?
It 's a bug in agent2d3.1.1?

Responder al #77269×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar