本文整理汇总了C++中Cell::GetRadius方法的典型用法代码示例。如果您正苦于以下问题:C++ Cell::GetRadius方法的具体用法?C++ Cell::GetRadius怎么用?C++ Cell::GetRadius使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cell
的用法示例。
在下文中一共展示了Cell::GetRadius方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCellContainer
std::vector<int>
NetworkManager::GetCellIDFromPosition (CartesianCoordinates *position)
{
std::vector<int> CellsID;
std::vector<Cell*>* cellContainer = GetCellContainer ();
std::vector<Cell*>::iterator iter;
Cell *cell;
double distance;
for (iter = cellContainer->begin ();
iter !=cellContainer->end (); iter++)
{
cell = *iter;
distance = sqrt (pow ((cell->GetCellCenterPosition()->GetCoordinateX() - position->GetCoordinateX()),2)
+ pow ((cell->GetCellCenterPosition()->GetCoordinateY() - position->GetCoordinateY()),2));
if (distance <= cell->GetRadius())
{
CellsID.push_back(cell->GetIdCell());
}
}
return CellsID;
}
示例2: if
void
Manhattan::UpdatePosition (double timestamp)
{
#ifdef MOBILITY_DEBUG
// cout << "\t START MOBILITY MODEL for "<< GetNodeID () << endl;
#endif
if (GetSpeed () == 0)
{
#ifdef MOBILITY_DEBUG
cout << "\t\t speed = 0 --> position has not been updated!"<< endl;
#endif
return;
}
double timeInterval = timestamp - GetPositionLastUpdate ();
double speedDirection;
UserEquipment *thisNode = NetworkManager::Init ()->GetUserEquipmentByID (GetNodeID ());
Cell *thisCell = thisNode->GetCell ();
NetworkNode *targetNode = thisNode->GetTargetNode ();
#ifdef MOBILITY_DEBUG
cout << "MOBILITY_DEBUG: User ID: " << GetNodeID ()
<< "\n\t Cell ID " <<
NetworkManager::Init()->GetCellIDFromPosition (GetAbsolutePosition()->GetCoordinateX(),
GetAbsolutePosition()->GetCoordinateY())
<< "\n\t Initial Position (X): " << GetAbsolutePosition()->GetCoordinateX()
<< "\n\t Initial Position (Y): " << GetAbsolutePosition()->GetCoordinateY()
<< "\n\t Speed: " << GetSpeed()
<< "\n\t Speed Direction: " << GetSpeedDirection()
<< "\n\t Time Last Update: " << GetPositionLastUpdate()
<< "\n\t Time Interval: " << timeInterval
<< endl;
#endif
#ifdef MOBILITY_DEBUG_TAB
cout << GetNodeID () << " "
<< GetAbsolutePosition()->GetCoordinateX() << " "
<< GetAbsolutePosition()->GetCoordinateY() << " "
<< GetSpeed() << " "
<< GetSpeedDirection() << " "
<< GetPositionLastUpdate() << " "
<< timeInterval << " "
<< "-> ";
#endif
const double pi = 3.14;
// Init speedDirection if its not pointing into the direction of Manhattans Streets
vector<double> directions;
for(int i=0;i<=3;i++) {
directions.push_back(i * 1.57); // 1.57 = 90.0 * ((2.0*pi)/360.0))
}
double newdir;
vector<double>::iterator it;
it = find(directions.begin(), directions.end(), GetSpeedDirection());
if(it == directions.end()) {
newdir = (double)(pi / 2) * round(GetSpeedDirection() * (double)(2 / pi));
if(newdir==6.28) newdir = 0;
SetSpeedDirection(newdir);
#ifdef MOBILITY_DEBUG_TAB
cout << "NEW SPEED-DIRECTION: " << newdir << " -> ";
#endif
}
double shift = timeInterval * (GetSpeed()*(1000.0/3600.0));
CartesianCoordinates *newPosition = new CartesianCoordinates(GetAbsolutePosition()->GetCoordinateX(), GetAbsolutePosition()->GetCoordinateY());
CartesianCoordinates *ENodeBPosition = targetNode->GetMobilityModel ()->GetAbsolutePosition ();
// Init Manhattan grid position
if(fmod(GetAbsolutePosition()->GetCoordinateY(),100)!=0 && fmod(GetAbsolutePosition()->GetCoordinateX(),100)!=0){
CartesianCoordinates *Correction = new CartesianCoordinates();
double distfromEnB = newPosition->GetDistance (ENodeBPosition);
double azim = newPosition->GetPolarAzimut (ENodeBPosition);
//if it was randomly put outside the cell -> shift it inside
if(distfromEnB > (thisCell->GetRadius()*1000)) {
Correction->SetCoordinates((newPosition->GetDistance (ENodeBPosition) - (thisCell->GetRadius()*1000)) * cos(azim),
(newPosition->GetDistance (ENodeBPosition) - (thisCell->GetRadius()*1000)) * sin(azim));
newPosition->SetCoordinates(newPosition->GetCoordinateX() - Correction->GetCoordinateX(),
newPosition->GetCoordinateY() - Correction->GetCoordinateY());
}
delete Correction;
if(GetSpeedDirection()==0 || GetSpeedDirection()==3.14) {
if(newPosition->GetCoordinateY() < 0)
newPosition->SetCoordinateY( ceil( (double)(newPosition->GetCoordinateY() / 100) ) * 100);
else
newPosition->SetCoordinateY( floor( (double)(newPosition->GetCoordinateY() / 100) ) * 100);
}
else {
if(newPosition->GetCoordinateX() < 0)
newPosition->SetCoordinateX( ceil( (double)(newPosition->GetCoordinateX() / 100)) * 100);
else
newPosition->SetCoordinateX( floor( (double)(newPosition->GetCoordinateX() / 100) ) * 100);
//.........这里部分代码省略.........