Exemplo n.º 1
0
int main(int argc, char** argv) {

	if (argc != 2) {
		usage(argv[0]);
		exit(1);
	}

	parse(argv[1]);

	//TestPoint();

	//Paving
	switch(dim) {
  case 1 : { //1D
    std::vector<Point<1> > v_points;
    for(size_t i = 0; i < matrix.size(); i++) {
      // recupère toutes les coordonnées (sauf la dernière)
      std::vector<float> _matrix(matrix[i].begin(), matrix[i].end() - 1);
      // on ajoute la valeur (dernier élément du vector)
      v_points.push_back(Point<1>(_matrix, matrix[i].back()));
    }
    Paving<1> pav(v_points);
    pav.init();
    menu1(pav);
    break; }
  case 2 : { //2D
    std::vector<Point<2> > v_points;
    for(size_t i = 0; i < matrix.size(); i++) {
      std::vector<float> _matrix(matrix[i].begin(), matrix[i].end() - 1);
      v_points.push_back(Point<2>(_matrix, matrix[i].back()));
    }
    Paving<2> pav(v_points);
    pav.init();
    menu2(pav);
    break; }
 case 3 : { //3D
    std::vector<Point<3> > v_points;
    for(size_t i = 0; i < matrix.size(); i++) {
      std::vector<float> _matrix(matrix[i].begin(), matrix[i].end() - 1);
      v_points.push_back(Point<3>(_matrix, matrix[i].back()));
    }
    Paving<3> pav(v_points);
    pav.init();
    menu3(pav);
    break; }
  case 4 : { //4D
    std::vector<Point<4> > v_points;
    for(size_t i = 0; i < matrix.size(); i++) {
      std::vector<float> _matrix(matrix[i].begin(), matrix[i].end() - 1);
      v_points.push_back(Point<4>(_matrix, matrix[i].back()));
    }
    Paving<4> pav(v_points);
    pav.init();
    pav.to_str();
    break; }
	}


	return 0;
}
 bool check_sum()
 {
   for (size_t column = 0; column < _matrix.size2(); ++column)
   {
     int sum = 0;
     for (size_t row = 0; row < _matrix.size1(); ++row)
     {
       sum += _choice[row] * _matrix(row, column);
     }
     if (sum < -1 || sum > +1)
       return false;
   }
   return true;
 }
Exemplo n.º 3
0
void Map::set(int row, int column, int value)
{
	int previews_value = get(row, column);

	switch (previews_value)
	{
	case (MAP_STATE_OBSTACLE):
		// Ignore this cell update

		break;

	default:
		_matrix(row, column) = value;
		break;
	}
}
void MatrixWriterDAT::write(void)
{
	std::ofstream dat_file;
	dat_file.open(_filename.c_str(), std::ios::out|std::ios::trunc);
	if(dat_file.is_open())
	{
		for(int i = 0; i < 4; i++)
		{
			for(int j = 0; j < 4; j++)
			{
				dat_file << _matrix(i,j) << " ";
			}
			dat_file << std::endl;
		}
		dat_file.close();
	}
	else
		std::cout << "Cannot open DAT file." << std::endl;
}
Exemplo n.º 5
0
//virtual
void ARTagNode::ARTagNodeCallback::operator()(osg::Node* node, osg::NodeVisitor* nv)
{

	bool found_marker = false;

    for (int i = 0; i<_detectedMarkers.size(); i++) {
        
        if(_detectedMarkers[i].id == _marker_id)
        {
			osg::Matrix transform;
            static osg::Matrix scale = osg::Matrix::scale(10.0,10.0,10.0);
            
            Matrix44 glMatrix = _detectedMarkers[i].transformation.getInverted().getMat44();
            _matrix.identity();
            _matrix(0,0) =  glMatrix.mat[0][0];
            _matrix(0,1) =  glMatrix.mat[1][0];
            _matrix(0,2) =  glMatrix.mat[2][0];
            _matrix(1,0) =  glMatrix.mat[0][1];
            _matrix(1,1) =  glMatrix.mat[1][1];
            _matrix(1,2) =  glMatrix.mat[2][1];
            _matrix(2,0) =  glMatrix.mat[0][2];
            _matrix(2,1) =  glMatrix.mat[1][2];
            _matrix(2,2) =  glMatrix.mat[2][2];
            
            _matrix(3,0) =  100.0*glMatrix.mat[3][0];
            _matrix(3,1) =  100.0*glMatrix.mat[3][2];
            _matrix(3,2) =  -100.0*glMatrix.mat[3][1];
            
            _matrix(3,3) =  1.0;
        
  
			// copy the transformation matrix
            _transform->setMatrix( _offset * (scale * _matrix) );
            found_marker = true;


			// switch on the 3D model 
			osg::Switch* s = reinterpret_cast<osg::Switch*>(node);
			if(s)s->setAllChildrenOn();
        }

        
    }
    if(!found_marker)
	{
		// if no marker has been found, switch off the 3d model 
		osg::Switch* s = reinterpret_cast<osg::Switch*>(node);
		if(s)s->setAllChildrenOff();
	}
    
    nv->traverse(*node);
}
Exemplo n.º 6
0
int Map::get(int row, int column) const
{
	// TODO: input checks

	return _matrix(row, column);
}
void MatrixReaderM::read()
{
#ifdef DEBUG
    std::cout << "Read matrix file ..." << std::endl;
#endif
    std::string line;
    std::ifstream file(_filename.c_str());
    std::vector<std::string> strs;
    uint row_num = 0;
    std::vector< Eigen::VectorXf > temp;

    if(file.is_open()==true)
    {

        //while(! ptsfile.eof())
        std::getline(file,line);
        while(file.good()==true)
        {
            if(line.at(0) == '#')
            {
                std::getline(file,line);
                continue;
            }

            Eigen::VectorXf v = Eigen::VectorXf::Zero(4,1);
            line = boost::trim_left_copy(line);
            line = boost::trim_right_copy(line);

            boost::split(strs, line, boost::is_any_of(" "));
            for(uint k = 0; k < strs.size(); k++)
                strs.at(k) = boost::algorithm::trim_copy(strs.at(k));
            if(strs.at(0).empty())
            {
                v(0) = double(atof(strs.at(1).c_str()));
                v(1) = double(atof(strs.at(2).c_str()));
                v(2) = double(atof(strs.at(3).c_str()));
                v(3) = double(atof(strs.at(4).c_str()));
            }
            else
            {
                v(0) = double(atof(strs.at(0).c_str()));
                v(1) = double(atof(strs.at(1).c_str()));
                v(2) = double(atof(strs.at(2).c_str()));
                v(3) = double(atof(strs.at(3).c_str()));
            }

            strs.clear();
            //_matrix(row_num,0) = v(0);
            //_matrix(row_num,1) = v(1);
            //_matrix(row_num,2) = v(2);
            temp.push_back(v);

            std::getline(file,line);
            if(file.eof()==true)
                break;
            row_num++;
        }
#ifdef DEBUG
        std::cout << "File reading operation done." << std::endl;
#endif
        file.close();
        _matrix = Eigen::MatrixXf::Zero(temp.size(),4);
        for(uint i = 0; i < temp.size(); i++)
        {
            _matrix(i,0) = temp.at(i)(0);
            _matrix(i,1) = temp.at(i)(1);
            _matrix(i,2) = temp.at(i)(2);
            _matrix(i,3) = temp.at(i)(3);
        }
        temp.clear();
    }
    else
        std::cout << "Unable to open empty matrix file" << std::endl;
    //_matrix = arma::Mat<double>(data, 4, 4);
    //_matrix = Eigen::MatrixXf()
}
Exemplo n.º 8
0
 auto operator()(const node_t& a, const node_t& b)
 {
     return _matrix(a.id(), b.id());
 }