• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Grid函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Grid函数的典型用法代码示例。如果您正苦于以下问题:C++ Grid函数的具体用法?C++ Grid怎么用?C++ Grid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Grid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: stepsVector

returnValue ModelData::setIntegrationGrid(	const Grid& _ocpGrid, const uint _numSteps
										)
{
	uint i;
	N = _ocpGrid.getNumIntervals();
	BooleanType equidistantControl = _ocpGrid.isEquidistant();
	double T = _ocpGrid.getLastTime() - _ocpGrid.getFirstTime();
	double h = T/((double)_numSteps);
	Vector stepsVector( N );

	if (integrationGrid.isEmpty() == BT_TRUE)
	{
		for( i = 0; i < stepsVector.getDim(); i++ )
		{
			stepsVector(i) = (int) acadoRound((_ocpGrid.getTime(i+1)-_ocpGrid.getTime(i))/h);
		}

		if( equidistantControl )
		{
			// Setup fixed integrator grid for equidistant control grid
			integrationGrid = Grid( 0.0, ((double) T)/((double) N), (int) ceil((double)_numSteps/((double) N) - 10.0*EPS) + 1 );
		}
		else
		{
			// Setup for non equidistant control grid
			// NOTE: This grid defines only one integration step because the control
			// grid is non equidistant.
			integrationGrid = Grid( 0.0, h, 2 );
			numSteps = stepsVector;
		}
	}
	return SUCCESSFUL_RETURN;
}
开发者ID:francesco-romano,项目名称:acado,代码行数:33,代码来源:model_data.cpp


示例2: Wall

Wall* Wall::create(Field* field, const Grid &pos)
{
    Wall* wall = new Wall();
    if (wall && wall->initWithGrid(field, "rWall_0003", pos))
    {
        wall->autorelease();
        wall->retain();
    }
    else
    {
        CC_SAFE_DELETE(wall);
        wall = nullptr;
    }
    
    wall->_is_top_wall_exist   = wall->_isWallExist(wall->m_grid_pos + Grid(0, -1));
    wall->_is_right_wall_exist = wall->_isWallExist(wall->m_grid_pos + Grid(1, 0));
    wall->_refreshWall();
    
    auto left_wall   = wall->_getWall(wall->m_grid_pos + Grid(-1, 0));

    if (left_wall)
    {
        left_wall->notifyRightWallExist();
    }
    
    auto bottom_wall = wall->_getWall(wall->m_grid_pos + Grid(0, 1));
    if (bottom_wall)
    {
        bottom_wall->notifyTopWallExist();
    }
    
    return wall;
}
开发者ID:wevet,项目名称:Cocos2dxResources,代码行数:33,代码来源:Wall.cpp


示例3: main

int main(){
  Grid g = Grid();

  Grid g2 = Grid();

  assert(g == g2);

  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      if ((i+j)%7 == 0) {
        g2.set(i,j,-1*(i+1)*(j+1));
      } else {
        g2.set(i,j,(i-1)*(j+1));
      }
    }
  }

  assert(g != g2);

  g = g2;

  assert (g == g2);

  g.set(8,8, -10);
  g.set(4,8, -10);
  g.set(3,8, -10);
  g.set(8,5, -10);
  g.set(1,3, -10);

  g.print();

  std::cout << "All tests passed!\n";

  return 0;
}
开发者ID:dhrupadb,项目名称:C-doku-,代码行数:35,代码来源:test_grid.cpp


示例4: int

Grid GameWorld::GetGridPos(float x, float y)
{
	if (x < rect.left || x >= rect.right || y > rect.top || y <= rect.bottom) return Grid(-1, -1);

	int tx = int((x - rect.left) / gridWidth);
	int ty = int((rect.top - y) / gridHeight);

	return Grid(tx, ty);
}
开发者ID:MagicBlocks,项目名称:Pac-man,代码行数:9,代码来源:GameWorld.cpp


示例5: getBrickAt

void Board::addDestroyedBricks(Brick* brick, std::vector<Brick*> &destroyedBricks)
{
    Grid location = brick->_currentLocation;
    Brick* north = getBrickAt(location + Grid(-1,0));
    Brick* south = getBrickAt(location + Grid(1,0));
    Brick* east = getBrickAt(location + Grid(0,1));
    Brick* west = getBrickAt(location + Grid(0,-1));
    
    if(north != 0 ) // not sure why some times short circuit works sometime it doesn't.
    {
        if(!north->tmp_moves)
        {
            if(brick->getType() == north->getType())
            {
                north->tmp_moves = true;    
                destroyedBricks.push_back(north);
            }
        }
    }
    if(south != 0 )
    {
        if(!south->tmp_moves)
        {
            if(brick->getType() == south->getType())
            {
                south->tmp_moves = true;    
                destroyedBricks.push_back(south);
            }
        }
    }
    if(east != 0)
    {
        if(!east->tmp_moves)
        {
            if(brick->getType() == east->getType() )
            {
                east->tmp_moves = true;    
                destroyedBricks.push_back(east);
            }
        }
    }
    if(west != 0 )
    {
        if(!west->tmp_moves)
        {
            if(brick->getType() == west->getType() )
            {
                west->tmp_moves = true;    
                destroyedBricks.push_back(west);
            }
        }
    }
}
开发者ID:ZwodahS,项目名称:DestroyTheBrick,代码行数:53,代码来源:Board.cpp


示例6: m_boundsManager

//#################### CONSTRUCTORS ####################
BroadPhaseCollisionDetector::BroadPhaseCollisionDetector(const BoundsManager_CPtr& boundsManager,
														 double minObjectSize, double maxObjectSize)
:	m_boundsManager(boundsManager)
{
	for(double gridSize=minObjectSize; gridSize<maxObjectSize*2; gridSize*=2)
	{
		m_hgrid.insert(std::make_pair(gridSize, Grid()));
	}

	m_hgrid.insert(std::make_pair(std::numeric_limits<double>::max(), Grid()));
}
开发者ID:longde123,项目名称:hesperus2,代码行数:12,代码来源:BroadPhaseCollisionDetector.cpp


示例7: Grid

bool Board::fireBrick(Grid location, Brick* nextBrick, zf::Direction direction)
{
    if(isMoving())
    {
        return false;
    }
    Grid directionGrid = Grid(0,0);
    switch(direction)
    {
        case zf::North:
            directionGrid = Grid(-1,0);
            break;
        case zf::South:
            directionGrid = Grid(1,0);
            break;
        case zf::East:
            directionGrid = Grid(0,1);
            break;
        case zf::West:
            directionGrid = Grid(0,-1);
            break;
    }
    Grid nextGrid = location + directionGrid;
    Brick* brick = getBrickAt(nextGrid.row , nextGrid.col);
    if(brick != 0)
    {
        return false; // if there is a brick blocking directly, don't allow it to shoot.
    }
    //find the first block that it will hit
    // move nextGrid back first
    nextGrid -= directionGrid;
    while(brick == 0)
    {
        nextGrid += directionGrid;
        Grid temp = nextGrid + directionGrid;
        if(!inShootableRange(temp.row,temp.col)) // if the next is not in shootable range , break
        {
            // prevent out of bound
            break;
        }
        brick = getBrickAt(temp.row, temp.col);
    }

    _knock = -1;
    putBrickInto(location.row,location.col,nextBrick);
    nextBrick->moveToLocation(nextGrid.row, nextGrid.col);
    _currentMovingDirection = directionGrid; 
    _movingBricks.push_back(nextBrick);
    return true;
}
开发者ID:ZwodahS,项目名称:DestroyTheBrick,代码行数:50,代码来源:Board.cpp


示例8: hasBot

bool World::hasBot(int row, int col)
{
    for(int i = 0 ; i < _enemyBots.size() ; i++)
    {
        if(_enemyBots[i]->getLocation() == Grid(row,col))
        {
            return true;
        }
    }
    if(_player->getLocation() == Grid(row, col))
    {
        return true;
    }
    return false;
}
开发者ID:ZwodahS,项目名称:LD26,代码行数:15,代码来源:World.cpp


示例9: GetSlot

void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player)
{
	const cItem * ResultSlot = GetSlot(0, a_Player);
	cItem & DraggingItem = a_Player.GetDraggingItem();

	// Get the current recipe:
	cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player);

	cItem * PlayerSlots = GetPlayerSlots(a_Player) + 1;
	cCraftingGrid Grid(PlayerSlots, m_GridSize, m_GridSize);

	// If possible, craft:
	if (DraggingItem.IsEmpty())
	{
		DraggingItem = Recipe.GetResult();
		Recipe.ConsumeIngredients(Grid);
		Grid.CopyToItems(PlayerSlots);
	}
	else if (DraggingItem.IsEqual(Recipe.GetResult()))
	{
		cItemHandler * Handler = ItemHandler(Recipe.GetResult().m_ItemType);
		if (DraggingItem.m_ItemCount + Recipe.GetResult().m_ItemCount <= Handler->GetMaxStackSize())
		{
			DraggingItem.m_ItemCount += Recipe.GetResult().m_ItemCount;
			Recipe.ConsumeIngredients(Grid);
			Grid.CopyToItems(PlayerSlots);
		}
	}

	// Get the new recipe and update the result slot:
	UpdateRecipe(a_Player);
	
	// We're done. Send all changes to the client and bail out:
	m_ParentWindow.BroadcastWholeWindow();
}
开发者ID:l0ud,项目名称:MCServer,代码行数:35,代码来源:SlotArea.cpp


示例10: run_soft_sphere

double run_soft_sphere(double reduced_density, double temp) {
  Functional f = SoftFluid(sigma, 1, 0);
  const double mu = find_chemical_potential(OfEffectivePotential(f), temp, reduced_density*pow(2,-5.0/2.0));
  printf("mu is %g for reduced_density = %g at temperature %g\n", mu, reduced_density, temp);

  //printf("Filling fraction is %g with functional %s at temperature %g\n", reduced_density, teff);
  //fflush(stdout);
  temperature = temp;
  //if (kT == 0) kT = ;1

  Lattice lat(Cartesian(xmax,0,0), Cartesian(0,ymax,0), Cartesian(0,0,zmax));
  GridDescription gd(lat, dx);

  Grid softspherepotential(gd);
  softspherepotential.Set(soft_sphere_potential);

  f = SoftFluid(sigma, 1, mu); // compute approximate energy with chemical potential mu
  const double approx_energy = f(temperature, reduced_density*pow(2,-5.0/2.0))*xmax*ymax*zmax;
  const double precision = fabs(approx_energy*1e-9);

  f = OfEffectivePotential(SoftFluid(sigma, 1, mu) + ExternalPotential(softspherepotential));

  static Grid *potential = 0;
  potential = new Grid(gd);
  *potential = softspherepotential - temperature*log(reduced_density*pow(2,-5.0/2.0)/(1.0*radius*radius*radius))*VectorXd::Ones(gd.NxNyNz); // Bad starting guess
  printf("\tMinimizing to %g absolute precision from %g from %g...\n", precision, approx_energy, temperature);
  fflush(stdout);

  Minimizer min = Precision(precision,
                            PreconditionedConjugateGradient(f, gd, temperature,
                                potential,
                                QuadraticLineMinimizer));
  took("Setting up the variables");
  for (int i=0; min.improve_energy(true) && i<100; i++) {
  }

  took("Doing the minimization");
  min.print_info();

  Grid density(gd, EffectivePotentialToDensity()(temperature, gd, *potential));
  //printf("# per area is %g at filling fraction %g\n", density.sum()*gd.dvolume/dw/dw, reduced_density);

  char *plotname = (char *)malloc(1024);

  sprintf(plotname, "papers/fuzzy-fmt/figs/radial-wca-%06.4f-%04.2f.dat", temp, reduced_density);
  z_plot(plotname, Grid(gd, pow(2,5.0/2.0)*density));
  free(plotname);

  {
    //double peak = peak_memory()/1024.0/1024;
    //double current = current_memory()/1024.0/1024;
    //printf("Peak memory use is %g M (current is %g M)\n", peak, current);

  }

  took("Plotting stuff");
  printf("density %g gives ff %g for reduced_density = %g and T = %g\n", density(0,0,gd.Nz/2),
         density(0,0,gd.Nz/2)*4*M_PI/3, reduced_density, temp);
  return density(0, 0, gd.Nz/2)*4*M_PI/3; // return bulk filling fraction
}
开发者ID:droundy,项目名称:deft,代码行数:60,代码来源:radial-wca.cpp


示例11: PushCallStack

inline void
AbstractDistMatrix<T,Int>::Write
( const std::string filename, const std::string msg ) const
{
#ifndef RELEASE
    PushCallStack("AbstractDistMatrix::Write");
#endif
    const elem::Grid& g = Grid();
    const int commRank = mpi::CommRank( g.VCComm() ); 

    if( commRank == 0 )
    {
        std::ofstream file( filename.c_str() );
        file.setf( std::ios::scientific );
        PrintBase( file, msg );
        file.close();
    }
    else
    {
        NullStream nullStream;
        PrintBase( nullStream, msg );
    }
#ifndef RELEASE
    PopCallStack();
#endif
}
开发者ID:jimgoo,项目名称:Elemental,代码行数:26,代码来源:abstract_impl.hpp


示例12: logic_error

inline void
AbstractDistMatrix<T,Int>::AssertSameGrid
( const AbstractDistMatrix<U,Int>& A ) const
{
    if( Grid() != A.Grid() )
        throw std::logic_error("Assertion that grids match failed");
}
开发者ID:jimgoo,项目名称:Elemental,代码行数:7,代码来源:abstract_impl.hpp


示例13: Grid

FixPaintSelection::GridMap::iterator
FixPaintSelection::addGrid(const Point& pt)
{
    std::pair<GridMap::iterator, bool> inserted =
        mGrids.insert(GridMap::value_type(pt, Grid()));
    return inserted.first;
}
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:7,代码来源:FixPaintAction.cpp


示例14: sol

Grid Grid::exact_solution(int time_steps) {
	std::vector<double> sol(size, 0);
	int shift = (int) (dt * xi / dh * time_steps / dh);
	for (int i = 0; i < size - shift; i++)
		sol[i + shift] = data[i];
	return Grid(sol, dh, dt, xi);
};
开发者ID:liviniuk,项目名称:MIPT_base,代码行数:7,代码来源:Grid.cpp


示例15: Game

		 : Game(rm, dbGraphics, screenBounds, gameFont, fontBrush, sound)
{
	// Create random instance
	rGen = gcnew Random();
	
	// Load background image
	//background = Image::FromFile("background.jpg");

	// Create gamegrid and preview
	grid = gcnew GameGrid(rm, Point(302,-30), graphics, sound, GAMEGRID_COLS, GAMEGRID_ROWS);
	preview = gcnew Grid(rm, Point(757,480), graphics, PREVIEW_COLS, PREVIEW_ROWS); 

	// Create arrays for tracking block stats
	tetriminoStats = gcnew array<int>(7);
	tetriminoTypes = gcnew array<ETetriminoType>
	{
		I_TETRIMINO,
		J_TETRIMINO, 
		L_TETRIMINO, 
		O_TETRIMINO, 
		S_TETRIMINO, 
		T_TETRIMINO,
		Z_TETRIMINO
	};

	// Create first two tetriminos
	tetriminoInPlay = generateTetrimino();
	nextTetrimino = generateTetrimino();

	// Initialize game update time
	waitTime = 50;
}
开发者ID:appsromch,项目名称:CPlusPlus,代码行数:32,代码来源:GamePlay.cpp


示例16: Grid

//Constructs the grid based on the polygon's bounding box and generates a random point if inside polygon
Points PathPlanner::getRandGridPoints(){
	//Grid
	CGAL::Bbox_2 box = this->BPpoly.bbox();
	long double xmini = box.xmin();
	long double ymini = box.ymin();
	long double xmaxi = box.xmax();
	long double ymaxi = box.ymax();
	cout<<xmini<<" "<<xmaxi<<" "<<ymini<<" "<<ymaxi<<'\n';
	Point_2 iterator;
	vector<Grid> grids;
	Points randGridPoints;
	for(long double i =ymini; i<ymaxi; i += this->gridSideLen ){
		for(long double j = xmini; j<xmaxi; j+= this->gridSideLen ){
			grids.push_back( Grid( Point_2(j,i) , this->gridSideLen) );
			cout<<"row: "<<i<<" column: "<<j<<'\n';
		}
	}
	for (int i =0 ; i <grids.size();i++){
		if(grids[i].is_bounded(BPpoly)){
			randGridPoints.push_back(grids[i].genRandPoint());
			grids[i].printGrid();
		}
	}
	return randGridPoints;

}
开发者ID:enc5271,项目名称:coverageAlgorithm,代码行数:27,代码来源:coverageAlgorithm.cpp


示例17: Parameters

//---------------------------------------------------------
bool CFilter_Resample::On_Execute(void)
{
	double		Cellsize;
	CSG_Grid	*pGrid, *pLoPass, *pHiPass;

	//-----------------------------------------------------
	pGrid		= Parameters("GRID"  )->asGrid();
	pLoPass		= Parameters("LOPASS")->asGrid();
	pHiPass		= Parameters("HIPASS")->asGrid();
	Cellsize	= Parameters("SCALE" )->asDouble() * Get_Cellsize();

	//-----------------------------------------------------
	if( Cellsize > 0.5 * SG_Get_Length(Get_System()->Get_XRange(), Get_System()->Get_YRange()) )
	{
		Error_Set(_TL("resampling cell size is too large"));

		return( false );
	}

	//-----------------------------------------------------
	CSG_Grid	Grid(CSG_Grid_System(Cellsize, Get_XMin(), Get_YMin(), Get_XMax(), Get_YMax()), SG_DATATYPE_Float);

	Grid.Assign(pGrid, GRID_RESAMPLING_Mean_Cells);

	//-----------------------------------------------------
	pLoPass->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pGrid->Get_Name(), _TL("Low Pass")));
	pHiPass->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pGrid->Get_Name(), _TL("High Pass")));

	CSG_Colors	Colors;

	DataObject_Get_Colors(pGrid  , Colors);
	DataObject_Set_Colors(pLoPass, Colors);
	DataObject_Set_Colors(pHiPass, 11, SG_COLORS_RED_GREY_BLUE);

	//-----------------------------------------------------
	for(int y=0; y<Get_NY() && Set_Progress(y); y++)
	{
		double	py	= Get_YMin() + y * Get_Cellsize();

		#pragma omp parallel for
		for(int x=0; x<Get_NX(); x++)
		{
			double	z, px	= Get_XMin() + x * Get_Cellsize();

			if( !pGrid->is_NoData(x, y) && Grid.Get_Value(px, py, z) )
			{
				pLoPass->Set_Value(x, y, z);
				pHiPass->Set_Value(x, y, pGrid->asDouble(x, y) - z);
			}
			else
			{
				pLoPass->Set_NoData(x, y);
				pHiPass->Set_NoData(x, y);
			}
		}
	}

	//-----------------------------------------------------
	return( true );
}
开发者ID:Fooway,项目名称:SAGA-GIS-git-mirror,代码行数:61,代码来源:Filter_Resample.cpp


示例18: Grid

void cSlotAreaCrafting::UpdateRecipe(cPlayer & a_Player)
{
	cCraftingGrid   Grid(GetPlayerSlots(a_Player) + 1, m_GridSize, m_GridSize);
	cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player);
	cRoot::Get()->GetCraftingRecipes()->GetRecipe(&a_Player, Grid, Recipe);
	SetSlot(0, a_Player, Recipe.GetResult());
	m_ParentWindow.SendSlot(a_Player, this, 0);
}
开发者ID:RedEnraged96,项目名称:MCServer-1,代码行数:8,代码来源:SlotArea.cpp


示例19: _getWall

void Wall::_destroy()
{
    Building::_destroy();
    m_field->notifyWallWatchers();
    
    auto left_wall   = _getWall(m_grid_pos + Grid(-1, 0));
    if (left_wall)
    {
        left_wall->notifyRightWallBroken();
    }
    
    auto bottom_wall = _getWall(m_grid_pos + Grid(0, 1));
    if (bottom_wall)
    {
        bottom_wall->notifyTopWallBroken();
    }
}
开发者ID:wevet,项目名称:Cocos2dxResources,代码行数:17,代码来源:Wall.cpp


示例20: fromVariantMap

bool Grid::fromVariantMap(const QVariantMap& vm)
{
    *this = Grid();
    valueFromVariantMap(vm, QLatin1String(KEY_VISIBLE), m_visible);
    valueFromVariantMap(vm, QLatin1String(KEY_SNAPX), m_snapX);
    valueFromVariantMap(vm, QLatin1String(KEY_SNAPY), m_snapY);
    valueFromVariantMap(vm, QLatin1String(KEY_DELTAX), m_deltaX);
    return valueFromVariantMap(vm, QLatin1String(KEY_DELTAY), m_deltaY);
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:9,代码来源:grid.cpp



注:本文中的Grid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Gt函数代码示例发布时间:2022-05-30
下一篇:
C++ GreenSystemMessage函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap