当前位置: 首页>>代码示例>>C++>>正文


C++ GridMap::getPositionFromIndex方法代码示例

本文整理汇总了C++中GridMap::getPositionFromIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ GridMap::getPositionFromIndex方法的具体用法?C++ GridMap::getPositionFromIndex怎么用?C++ GridMap::getPositionFromIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GridMap的用法示例。


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

示例1: calcRepulsiveForceSum

void BasicVFF::calcRepulsiveForceSum(const GridMap &map)
{
    for(int i = 0; i < map.getMapSize().y; i++)
    {
        for(int j = 0; j < map.getMapSize().x; j++)
        {
			uchar occupancyData = map.getOccupancyGridMap()[i * map.getMapSize().x + j];
            if(occupancyData > 0)
            {
                Position2f ObstaclePos;
                map.getPositionFromIndex(Cell2i(i,j), ObstaclePos);
                //cout << i << " " << j << endl;
                //cout << ObstaclePos.x << " " << ObstaclePos.y << endl;
                float distancePow = getDistancePow(ObstaclePos);
                float distance = powf(distancePow, 0.5);
                force2f force = force2f((0 - ObstaclePos.x) / distance , (0 - ObstaclePos.y) / distance);
                float coeff = (float)occupancyData / distancePow;
                //cout << (float)occupancyData << " "<< distancePow << " " << coeff<< endl;

                force2f force1 = coeff * force;
                forceSum += force1;
                //cout << force.x << " " << force.y << endl;
                //cout << force1.x << " " << force1.y << endl;
            }
        }
    }

    cout << "ForceSum = " << forceSum.x << " "<< forceSum.y << endl;
}
开发者ID:Yvaine,项目名称:avoidance_visual,代码行数:29,代码来源:BasicVFF.cpp

示例2: calcDistanceVecArray

void BasicVFF::calcDistanceVecArray(const GridMap &map)
{
    for(int i = 0; i < map.getMapSize().y; i++)
    {
        for(int j = 0; j < map.getMapSize().x; j++)
        {
			if (map.getOccupancyGridMap()[i * map.getMapSize().x + j] > 0)
            {
                Position2f ObstaclePos;
                map.getPositionFromIndex(Cell2i(i,j), ObstaclePos);
                cout << i << " " << j << endl;
                cout << ObstaclePos.x << " " << ObstaclePos.y << endl;
                distance_vec_array.push_back(ObstaclePos);
                cout << distance_vec_array.size() << endl;

            }

        }
    }
}
开发者ID:Yvaine,项目名称:avoidance_visual,代码行数:20,代码来源:BasicVFF.cpp


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