Exemplo n.º 1
0
//returns a vector of locations around a location
vector<location> getAdjacent(location myLoc)
{
  vector<location> returnVector(6);
  
  for(unsigned int o=0;o<6;o++)
  {
    returnVector[o] = myLoc + offset[o];
  }
  return returnVector;
}
Exemplo n.º 2
0
QVector<double> Command_Helper::convert_setHome(const int &useCurrent,const GPS_Position &Position)
{
    QVector<double> returnVector(7);
    returnVector.insert(0 , (double)useCurrent);
    returnVector.insert(1 , 0.0);
    returnVector.insert(2 , 0.0);
    returnVector.insert(3 , 0.0);
    returnVector.insert(4 , Position.Latitude);
    returnVector.insert(5 , Position.Longitude);
    returnVector.insert(6 , Position.Altitude);

    return(returnVector);
}
Exemplo n.º 3
0
QVector<double> Command_Helper::convert_takeOff(const GPS_Position &Position)
{
    QVector<double> returnVector(7);
    returnVector.insert(0 , 0.0);
    returnVector.insert(1 , 0.0);
    returnVector.insert(2 , 0.0);
    returnVector.insert(3 , 0.0);
    returnVector.insert(4 , Position.Latitude);
    returnVector.insert(5 , Position.Longitude);
    returnVector.insert(6 , Position.Altitude);

    return(returnVector);
}
Exemplo n.º 4
0
        const std::vector<unsigned char> Host::I2cRead(const unsigned int i2cAdress, const unsigned int dataLenght) {
            if (this->i2cHandler != -1 && dataLenght) {
                this->I2cSetAdress(i2cAdress);

#ifdef __linux__
                std::vector<unsigned char> returnVector(dataLenght);
                if (write(this->i2cHandler, &returnVector[0], dataLenght) != dataLenght) {
                    throw std::runtime_error("Failed to read from I2c-Slave");
                }
                return returnVector;
#endif
            }
            return std::vector<unsigned char>(0);
        }
Exemplo n.º 5
0
//returns a vector of only valid moves
vector<location> AI::validMoves(int x, int y)
{
  bool valid[] = {true,true,true,true,true,true};
  int stillValid=6;
  for(unsigned int o=0;o<6;o++)
  {
    if(!inBounds(x+offset[o].x,y+offset[o].y))
    {
      valid[o] = false;
      stillValid--;
    }
    for(unsigned int w=0;valid[o] && w<walls.size();w++)
    {
      if(walls[w].x()==x+offset[o].x && walls[w].y()==y+offset[o].y)
      {
        valid[o]=false;
        stillValid--;
      }
    }
    for(unsigned int z=0;valid[o] && z<zombies.size();z++)
    {
      if(zombies[z].x()==x+offset[o].x && zombies[z].y()==y+offset[o].y)
      {
        valid[o]=false;
        stillValid--;
      }
    }
    for(unsigned int h=0;valid[o] && h<humans.size();h++)
    {
      if(humans[h].x()==x+offset[o].x && humans[h].y()==y+offset[o].y)
      {
        valid[o]=false;
        stillValid--;
      }
    }
  }
  location myLocation(x,y);
  vector<location> returnVector(stillValid);
  for(unsigned int o=0,i=0;o<6;o++)
  {
    if(valid[o])
    {
      returnVector[i] = myLocation+offset[o];
      i++;
    }
  }
  return returnVector;
}
Exemplo n.º 6
0
/** Returns a vector with specified size based on an input vector.
 *
 *  This method "corrects" the size of a given input vector:
 *    - If the vector is empty or size is 0, the method throws an
 *std::invalid_argument exception.
 *    - If the vector already has the correct size, the vector is returned
 *unchanged.
 *    - If the vector contains more than "size" elements, the first "size"
 *elements are returned.
 *    - If the vector is smaller than "size", it is expanded to "size", all new
 *elements being equal to the last element of the input vector.
 *
 *  The method is used to make sure tolerance- and contribution-vectors have a
 *length
 *  that matches the number of expected phases. If only 1 tolerance is supplied
 *but 3 phases,
 *  this method creates a vector of 3 tolerance-values (all equal to the 1 value
 *that was supplied).
 *
 *  @param vector :: Input vector of length n, n > 0.
 *  @param size :: Length of output vector m, m > 0.
 *
 *  @return Vector of length m, content depends on input vector.
 */
std::vector<double>
PoldiIndexKnownCompounds::reshapeVector(const std::vector<double> &vector,
                                        size_t size) const {
    if (vector.empty() || size == 0) {
        throw std::invalid_argument("Cannot process empty vector.");
    }

    if (vector.size() == size) {
        return vector;
    }

    if (vector.size() > size) {
        return std::vector<double>(vector.begin(), vector.begin() + size);
    }

    std::vector<double> returnVector(vector);
    returnVector.resize(size, vector.back());

    return returnVector;
}
Exemplo n.º 7
0
std::vector<double>
XdmfGeometry::getOrigin() const
{
  std::vector<double> returnVector(mOrigin);
  return returnVector;
}
Exemplo n.º 8
0
 std::vector<float> Velocity6D::toVector(void) const
 {
   std::vector<float> returnVector(6, 0.0f);
   this->toVector(returnVector);
   return returnVector;
 }
Exemplo n.º 9
0
 std::vector<float> Position3D::toVector(void) const
 {
   std::vector<float> returnVector(3, 0.0f);
   this->toVector(returnVector);
   return returnVector;
 }