Exemplo n.º 1
0
int main(int agrc, char** argv)
{
    Mat R, T, intrinsicMatrix;
    
    zExternalParameter(argv[1], R, T, intrinsicMatrix);
    cout << R << T << endl;
    
    Mat origin(3,2,CV_64FC1);
    Mat direction(3,2,CV_64FC1);
    Mat tempVec(3,1,CV_64FC1);
    Mat dst(3,1,CV_64FC1);
    double x0,y0,x1,y1;
    cin >> x0;
    while(x0>0)
    {
        cin >> y0 >> x1 >> y1;
        origin.col(0) = origin.col(0) * 0;
        tempVec.at<double>(0,0) = x0;
        tempVec.at<double>(1,0) = y0;
        tempVec.at<double>(2,0) = 1;
        direction.col(0) = intrinsicMatrix.inv()*tempVec;
        origin.col(1) = -R*T;
        tempVec.at<double>(0,0) = x1;
        tempVec.at<double>(1,0) = y1;
        tempVec.at<double>(2,0) = 1;
        direction.col(1) = R*intrinsicMatrix.inv()*tempVec;
        zMeanDistancePoint(2, origin, direction, dst);
        cout << dst.at<double>(0,0) << " " << dst.at<double>(1,0) << " " << dst.at<double>(2,0) << endl;
        
        cin >> x0;
    }
    return 0;
}
Exemplo n.º 2
0
//Function to Initialize the substitution matrices for each branch length
void PairInitializer::InitOverallSubstitutionMatrices() {
    //Init SubModel
    if (Params->Get_SubModel().compare("F84")==0) {
        f84 = new F84Model(Params->Get_BaseFreq(), Params->Get_Kappa());
    } else if (Params->Get_SubModel().compare("TN93")==0) {
        tn93 = new TN93Model(Params->Get_BaseFreq(), Params->Get_AG_Rate(), Params->Get_CT_Rate());
    } else if (Params->Get_SubModel().compare("GTR")==0) {
        gtr = new GTRModel(Params->Get_BaseFreq(), Params->Get_X1_Param(), Params->Get_X2_Param(), Params->Get_X3_Param(), Params->Get_X4_Param(), Params->Get_X5_Param(), Params->Get_X6_Param());
    }

    //Compute Substitution Matrices according to the Selected Substitution Model
    DoubleVec tempVec(16, 0.0);
    for (int i=0; i<FTree->Get_UniqueLengths().size(); i++) {
        double* subM = NULL;
        if (Params->Get_SubModel().compare("F84")==0) {
            subM = f84->GetSubstitutionMatrix(FTree->Get_UniqueLengths()[i]);
        } else if (Params->Get_SubModel().compare("TN93")==0) {
            subM = tn93->GetSubstitutionMatrix(FTree->Get_UniqueLengths()[i]);
        } else if (Params->Get_SubModel().compare("GTR")==0) {
            subM = gtr->GetSubstitutionMatrix(FTree->Get_UniqueLengths()[i]);
        }

        for (int j=0; j<tempVec.size(); j++) {
            tempVec[j] = subM[j];
        }
        OverallSubMats.push_back(tempVec);
        OverallSubMatsLengths.push_back(FTree->Get_UniqueLengths()[i]);
    }
}
Exemplo n.º 3
0
int main(int argc, char** argv)
{
    srand((unsigned)time(NULL));
    ifstream inf(argv[1]);
    int n1, n2;
    double cx, cy, fx;
    inf >> n1 >> n2 >>fx >> cx >> cy;
    Mat intrinsicMatrix=Mat::zeros(3,3,CV_64FC1);
    intrinsicMatrix.at<double>(0,0) = fx;
    intrinsicMatrix.at<double>(1,1) = fx;
    intrinsicMatrix.at<double>(0,2) = cx/2;
    intrinsicMatrix.at<double>(1,2) = cy/2;
    intrinsicMatrix.at<double>(2,2) = 1;
    Mat R(3,3,CV_64FC1);
    Mat T(3,1,CV_64FC1);
    CvPoint2D32f line11[200];
    CvPoint2D32f line12[200];
    CvPoint2D32f line21[200];
    CvPoint2D32f line22[200];
    int i;
    for(i = 0; i<n1; i++) inf >> line11[i].x >> line11[i].y;
    for(i = 0; i<n2; i++) inf >> line12[i].x >> line12[i].y;
    for(i = 0; i<n1; i++) inf >> line21[i].x >> line21[i].y;
    for(i = 0; i<n2; i++) inf >> line22[i].x >> line22[i].y;
    inf.close();
    if(abs(fx)>1) zTwoLineCameraPose(n1, line11, line21, n2, line12, line22, 10, R, T, intrinsicMatrix, 1); else zTwoLineCameraPose(n1, line11, line21, n2, line12, line22, 10, R, T, intrinsicMatrix, 0);
    //if(abs(fx)>1) zTwoLineCameraPose2(0, n1, line11, line21, 0, n2, line12, line22, 10, R, T, intrinsicMatrix, 1); else zTwoLineCameraPose2(0, n1, line11, line21, 0, n2, line12, line22, 10, R, T, intrinsicMatrix, 0);
    cout << "RT" << R << endl << T << endl;
    Mat origin(3,2,CV_64FC1);
    Mat direction(3,2,CV_64FC1);
    Mat tempVec(3,1,CV_64FC1);
    Mat dst(3,1,CV_64FC1);
    double x0,y0,x1,y1;
    cin >> x0;
    while(x0>0)
    {
        cin >> y0 >> x1 >> y1;
        origin.col(0) = origin.col(0) * 0;
        tempVec.at<double>(0,0) = x0;
        tempVec.at<double>(1,0) = y0;
        tempVec.at<double>(2,0) = 1;
        direction.col(0) = intrinsicMatrix.inv()*tempVec;
        origin.col(1) = -R*T;
        tempVec.at<double>(0,0) = x1;
        tempVec.at<double>(1,0) = y1;
        tempVec.at<double>(2,0) = 1;
        direction.col(1) = R*intrinsicMatrix.inv()*tempVec;
        zMeanDistancePoint(2, origin, direction, dst);
        cout << dst.at<double>(0,0) << " " << dst.at<double>(1,0) << " " << dst.at<double>(2,0) << endl;
        
        cin >> x0;
    }
    return 0;
    
}
Exemplo n.º 4
0
float ControllableRobt::moveForward()
{
    float tmpTime = timer.getElapsedTime();
    VectorClass tempVec(speed * cos(degree), speed * sin(degree));
    float delta = tempVec.getLength() * tmpTime;
    if (delta > 5)
        return 0;
    setPosition(getPosition().x + tmpTime * tempVec.getX(),
                getPosition().y + tmpTime * tempVec.getY());
    return delta;
}
std::vector<OneDigg> DiggsVectorAnalyzer::getDiggsWithUniqueDates() const {
    std::vector<OneDigg> tempVec(diggs_);
    sort(begin(tempVec), end(tempVec),
    [](const OneDigg &first, const OneDigg &second) {
        return first.getAddDate() < second.getAddDate();
    });
    auto it = unique(begin(tempVec), end(tempVec),
    [](const OneDigg &first, const OneDigg &second) {
        return first.getAddDate() == second.getAddDate();
    });
    tempVec.resize( std::distance(tempVec.begin(),it), OneDigg("NOT_USED","NOT_USED", 0, "NOT_USED", "NOT_USED") );
    return tempVec;
}
	Jacobian computeJacobian(int i, Matrix3f X, MatrixXf Z){

		Jacobian jac;

		float c = X(0,0);
		float s = X(1,0);

		Matrix2f Rprime;

		jac << 1, 0, 0, 0, 1, 0;

		Rprime << -s, -c, c, -s;

		Vector2f tempVec(Z(0, i), Z(1, i));

		tempVec = Rprime*tempVec;

		jac(0, 2) = tempVec(0,0);
		jac(1, 2) = tempVec(1,0);

		return jac;

	}
Exemplo n.º 7
0
  void Vector4D::operator*=(const Matrix4x4& _multipliedMat4)
  {
    Vector4D tempVec(*this);

    Vector4D matRow1(_multipliedMat4.GetRow(0));
    Vector4D matRow2(_multipliedMat4.GetRow(1));
    Vector4D matRow3(_multipliedMat4.GetRow(2));
    Vector4D matRow4(_multipliedMat4.GetRow(3));

    m_x = StaticFunctions::Dot(matRow1, tempVec);
    m_y = StaticFunctions::Dot(matRow2, tempVec);
    m_z = StaticFunctions::Dot(matRow3, tempVec);
    m_w = StaticFunctions::Dot(matRow4, tempVec);
  }
Exemplo n.º 8
0
void PrintVecBinH(Cpu::int_vector &temp){
    std::string outFile("./temp.bin");
    std::ofstream ofs(outFile.c_str(), std::ofstream::binary);
    if (!ofs.good()){
	std::cout << "Fail to open " << outFile << std::endl;
	return;
    }else{
	std::vector<real_t> tempVec(temp.begin(), temp.end());
	for(int i=0; i<tempVec.size(); i++){
	    ofs.write((char *)&(tempVec[i]), sizeof(real_t));
	}
	ofs.close();
	std::cout << "Save to " << outFile << std::endl;
    }
}
	float CSolidNoice::dturbulence(const CVector3& vec, int depth, float d) const
	{
		float weight = 1.0f;
		CVector3 tempVec(vec);

		float sum = fabs(noice(tempVec)) / d;

		for (int i = 0; i < depth; ++i)
		{
			weight = weight * d;
			tempVec *= weight;

			sum += fabs(noice(tempVec)) / d;
		}

		return sum;
	}
Exemplo n.º 10
0
  void copyFromMxArray(std::vector<std::vector<T> >& dataVec)
  {
    double *matlabData = static_cast<double*>(mxGetPr(m_pMxArray));
    int numberColumns = mxGetN(m_pMxArray);
    int numberRows = mxGetM(m_pMxArray);

    std::vector<T> tempVec(numberRows);
    dataVec.resize(numberColumns);

    for(int col=0; col<numberColumns; ++col) {
      for(int row=0; row<numberRows; ++row) {
        int index = col * numberRows + row;
        tempVec[row] = (static_cast<T>(matlabData[index]));
      }
      dataVec[col] = tempVec;
    }
  }
Exemplo n.º 11
0
	float CSolidNoice::turbulence(const CVector3& vec, int depthM) const
	{
		float sum = 0.0f;
		float weight = 1.0f;
		CVector3 tempVec(vec);

		sum = fabs(noice(tempVec));

		for (int i = 1; i < depthM; ++i)
		{
			weight *= 2;
			tempVec *= weight;

			sum += fabs(noice(tempVec));
		}

		return sum;
	}
/********** routine de d�lacement **********/ 
int itsHybridContinuousInteractingAntColony::antMoveMessages( int antId )
{
  int i = antMessageChoose( antId );

  // si impossible de choisir un message
  if ( i==0 ) {

    return 0;
  }
  // antMessageChoose renvoi (index +1)
  // ok car index de 0 correspond �un vecteur nul de remplissage
  // FIXME : remplacer le vecteur de message par une matrice creuse?
  //i = i-1;

  int res = 0;
  // si valeur message meilleure
  // FIXME : comparer tout les messages? aller sur le meilleur message m�e si moins bon?
  if ( antIncomingValues[antId][i] < antCurrentValue[antId] ) {
    
    // bruite le point final
    /*vector<double> newPoint = RandomVector_Noise( 
						 antIncomingPoints[antId][i],
						 antMoveRange[antId]
						 );*/
    vector<double> tempVec( this->getProblem()->getDimension(), antMoveRange[antId]);
    vector<double> newPoint = noiseUniform( 
						 antIncomingPoints[antId][i],
						 tempVec
						 );

    // essaye de bouger
    res = antMoveTo( antId, newPoint );
  }

  
  // efface le message
  antIncomingPoints[antId].erase( antIncomingPoints[antId].begin() + i );
  antIncomingValues[antId].erase( antIncomingValues[antId].begin() + i );
  
  return res;
}
/********** d�lacement al�toire **********/ 
int itsHybridContinuousInteractingAntColony::antMoveRandom( int antId ) 
{
  vector<double> aPoint;
  aPoint.reserve( this->getProblem()->getDimension() );

  // tire une position au hasard dans l'espace
  //aPoint = RandomVector_Cube( getBoundsMinima(), getBoundsMaxima() );

  // modifie le vecteur de la fourmi

  // ajoute du bruit
  //aPoint = RandomVector_Noise( antCurrentPoint[antId], antMoveRange[antId]  );
  vector<double> tempVec( this->getProblem()->getDimension(),antMoveRange[antId] );
  aPoint = noiseUniform( antCurrentPoint[antId], tempVec  );
  
  if ( antMoveTo( antId, aPoint ) ) {
    return 1;
  } else {
    return 0;
  }
}
Exemplo n.º 14
0
/**
 * @brief Captures random bytes from OS generator.
 *
 * @param size_t with number of bytes to be recorded (default 1MB).
 *
 * @return true, if bytes were generated successfully.
 */
bool InterfaceOSRNG::generateRandomBytes(size_t numBytes) {
	// Compute total storage required.
	size_t requiredStorage = _osrngData.size() + numBytes;

	try {
		// Check if data can be held.
		if (_osrngData.max_size() < requiredStorage) {
			// Update numBytes to max possible.
			numBytes = _osrngData.max_size() - _osrngData.size();

			// Reserve max size.
			_osrngData.reserve(_osrngData.max_size());
		} else {
			_osrngData.reserve(requiredStorage);
		}

		std::vector<uint8_t> tempVec(numBytes);

		try {
			// Generate numBytes from OS generator.
			_generator.GenerateBlock(tempVec.data(), numBytes);
		} catch (...) {
			std::cerr << "[Failed] OS RNG failed to generate bytes" << std::endl;
			return false;
		}

		// Copy bytes and update bit occurrence.
		copyNCompEntropy(
			tempVec.begin(),
			tempVec.end(),
			std::back_inserter(_osrngData)
		);
	} catch (const std::bad_alloc& ba) {
		std::cerr << "[Memory Error] Samples discarded." << std::endl;
		return false;
	}

	return true;
}
Exemplo n.º 15
0
//! compute the median value of a vector
//! @param[in] &vector	reference to the vector to get the median from
//! @return			    median of vector
double median(rowvec &vector)
{
	int min = 0;
	rowvec tempVec = vector;

	for (unsigned int i = 0; i < vector.n_cols; i++)
	{
		min = i;
		for (unsigned int j = i; j < vector.n_cols; j++)
		{
			if (tempVec(min) > tempVec(j))
				min = j;
		}

		double temp = tempVec(i);
		tempVec(i) = tempVec(min);
		tempVec(min) = temp;
	}

	return tempVec(vector.n_cols / 2);
}
Exemplo n.º 16
0
//! Returns the result of a Epetra_Operator applied to a Epetra_MultiVector X in Y.
int QCAD::CoupledPSJacobian::Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
{ 
  //int disc_nGlobalElements = discMap->NumGlobalElements();
  int disc_nMyElements = discMap->NumMyElements();
  int nEigenvals = neg_eigenvalues->GlobalLength();

  Teuchos::RCP<Epetra_Vector> x_poisson, y_poisson;
  Teuchos::RCP<Epetra_MultiVector> x_schrodinger, y_schrodinger;
  Teuchos::RCP<Epetra_Vector> x_neg_evals, y_neg_evals;
  double *x_data, *y_data;

  Epetra_Vector tempVec(*discMap); //we could allocate this in initialize instead of on stack...
  Epetra_Vector tempVec2(*discMap); //we could allocate this in initialize instead of on stack...

  for(int i=0; i < X.NumVectors(); i++) {

    // Split X(i) and Y(i) into vector views for Poisson and Schrodinger parts
    if(X(i)->ExtractView(&x_data) != 0 || Y(i)->ExtractView(&y_data) != 0) 
      TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
				 "Error!  QCAD::CoupledPSJacobian -- cannot extract vector views");

    x_poisson = Teuchos::rcp(new Epetra_Vector(::View, *discMap, &x_data[0]));
    x_schrodinger = Teuchos::rcp(new Epetra_MultiVector(::View, *discMap, &x_data[disc_nMyElements], disc_nMyElements, nEigenvals));
    x_neg_evals = Teuchos::rcp(new Epetra_Vector(::View, *dist_evalMap, &x_data[(1+nEigenvals)*disc_nMyElements]));

    y_poisson = Teuchos::rcp(new Epetra_Vector(::View, *discMap, &y_data[0]));
    y_schrodinger = Teuchos::rcp(new Epetra_MultiVector(::View, *discMap, &y_data[disc_nMyElements], disc_nMyElements, nEigenvals));
    y_neg_evals = Teuchos::rcp(new Epetra_Vector(::View, *dist_evalMap, &y_data[(1+nEigenvals)*disc_nMyElements]));

    // Communicate all the x_evals to every processor, since all parts of the mesh need them
    x_neg_evals_local->Import(*x_neg_evals, *eval_importer, Insert);


    // Jacobian Matrix is:
    //
    //                   Phi                    Psi[i]                            -Eval[i]
    //          | ------------------------------------------------------------------------------------------|
    //          |                      |                             |                                      |
    // Poisson  |    Jac_poisson       |   M*diag(dn/d{Psi[i](x)})   |        -M*col(dn/dEval[i])           |
    //          |                      |                             |                                      |
    //          | ------------------------------------------------------------------------------------------|
    //          |                      |                             |                                      |
    // Schro[j] |  M*diag(-Psi[j](x))  | delta(i,j)*[ H-Eval[i]*M ]  |        delta(i,j)*M*Psi[i](x)        |    
    //          |                      |                             |                                      |
    //          | ------------------------------------------------------------------------------------------|
    //          |                      |                             |                                      |
    // Norm[j]  |    0                 | -delta(i,j)*(M+M^T)*Psi[i]  |                   0                  |
    //          |                      |                             |                                      |
    //          | ------------------------------------------------------------------------------------------|
    //
    //
    //   Where:
    //       n = quantum density function which depends on dimension
    
    // Scratch:  val = sum_ij x_i * M_ij * x_j
    //         dval/dx_k = sum_j!=k M_kj * x_j + sum_i!=k x_i * M_ik + 2* M_kk * x_k
    //                   = sum_i (M_ki + M_ik) * x_i
    //                   = sum_i (M + M^T)_ki * x_i  == k-th el of (M + M^T)*x
    //   So d(x*M*x)/dx = (M+M^T)*x in matrix form

    // Do multiplication block-wise

    // y_poisson =     
    poissonJacobian->Multiply(false, *x_poisson, *y_poisson); // y_poisson = Jac_poisson * x_poisson
    for(int i=0; i<nEigenvals; i++) {
      tempVec.Multiply(1.0, *((*dn_dPsi)(i)), *((*x_schrodinger)(i)), 0.0);  //tempVec = dn_dPsi[i] @ x_schrodinger[i]   (@ = el-wise product)
      massMatrix->Multiply(false, tempVec, tempVec2);  
      y_poisson->Update(1.0, tempVec2, 1.0);                                 // y_poisson += M * (dn_dPsi[i] @ x_schrodinger[i])

      tempVec.Update( -(*x_neg_evals_local)[i], *((*dn_dEval)(i)), 0.0); // tempVec = -dn_dEval[i] * scalar(x_neg_eval[i])
      massMatrix->Multiply(false, tempVec, tempVec2);
      y_poisson->Update( 1.0, tempVec2, 1.0); // y_poisson += M * (-dn_dEval[i] * scalar(x_neg_eval[i]))

      //OLD: y_poisson->Multiply(1.0, *((*dn_dPsi)(i)), *((*x_schrodinger)(i)), 1.0); // y_poisson += dn_dPsi[i] @ x_schrodinger[i]   (@ = el-wise product)
      //OLD: y_poisson->Update( -(*x_neg_evals_local)[i], *((*dn_dEval)(i)), 1.0); // y_poisson += -dn_dEval[i] * scalar(x_neg_eval[i])
    }

    // y_schrodinger =
    for(int j=0; j<nEigenvals; j++) {

      schrodingerJacobian->Multiply(false, *((*x_schrodinger)(j)), *((*y_schrodinger)(j)) ); // y_schrodinger[j] = H * x_schrodinger[j]
      massMatrix->Multiply(false, *((*x_schrodinger)(j)), tempVec );
      (*y_schrodinger)(j)->Update( (*neg_eigenvalues)[j], tempVec, 1.0); // y_schrodinger[j] += -eval[j] * M * x_schrodinger[j] 

      //tempVec.PutScalar(offset_to_CB);
      //tempVec.Update( -1.0, *((*psiVectors)(j)), 1.0);
      tempVec.Multiply( -1.0, *((*psiVectors)(j)), *x_poisson, 0.0); // tempVec = (-Psi[j]) @ x_poisson
      massMatrix->Multiply(false, tempVec, tempVec2);  
      (*y_schrodinger)(j)->Update( 1.0, tempVec2, 1.0); // y_schrodinger[j] += M * ( (-Psi[j]) @ x_poisson )

      //OLD: (*y_schrodinger)(j)->Multiply( -1.0, *((*psiVectors)(j)), *x_poisson, 1.0); // y_schrodinger[j] += (-Psi[j]) @ x_poisson
      (*y_schrodinger)(j)->Update( (*x_neg_evals_local)[j], *((*M_Psi)(j)), 1.0); // y_schrodinger[j] += M*Psi[j] * scalar(x_neg_eval[j])
    }
      
    // y_neg_evals =
    std::vector<double> y_neg_evals_local(nEigenvals);
    for(int j=0; j<nEigenvals; j++) {
      tempVec.Update(-1.0, *((*M_Psi)(j)), -1.0, *((*MT_Psi)(j)), 0.0); //tempVec = -(M*Psi[j] + MT*Psi[j]) = -(M+MT)*Psi[j]
      tempVec.Dot( *((*x_schrodinger)(j)), &y_neg_evals_local[j] );
    }
      // Fill elements of y_neg_evals that belong to this processor
    int my_nEigenvals = dist_evalMap->NumMyElements();
    std::vector<int> eval_global_elements(my_nEigenvals);
    dist_evalMap->MyGlobalElements(&eval_global_elements[0]);
    for(int i=0; i<my_nEigenvals; i++)
      (*y_neg_evals)[i] = y_neg_evals_local[eval_global_elements[i]];

  }
  return 0;
}
Exemplo n.º 17
0
bool SceneLoader::parseNode(TiXmlElement *XMLNode)
{
	TiXmlElement *XMLRotation;
	TiXmlElement *XMLPosition;
	TiXmlElement *XMLEntity;
	TiXmlElement *XMLScale;
	TiXmlElement *XMLProperty;

	Ogre::String  nodeName;
	Ogre::String  meshName;
	Ogre::String  meshFile;
	Ogre::Vector3 vec3Position;
	Ogre::Vector3 vec3Scale;
	Ogre::Quaternion quatRotation;

	Ogre::Entity *ent;


	//Get the name of the node
	nodeName = XMLNode->Attribute("name");
	std::cout << "NodeName: " << nodeName << std::endl;

	//Get the position element;
	XMLPosition = XMLNode->FirstChildElement("position");
	vec3Position.x = Ogre::StringConverter::parseReal(XMLPosition->Attribute("x"));
	vec3Position.y = Ogre::StringConverter::parseReal(XMLPosition->Attribute("y"));
	vec3Position.z = Ogre::StringConverter::parseReal(XMLPosition->Attribute("z"));
	//Debug text
	std::cout << "Position: " << "x: " << XMLPosition->Attribute("x");
	std::cout << " y: " << XMLPosition->Attribute("y");
	std::cout << " z: " << XMLPosition->Attribute("z") << std::endl;

	//Get the rotation
	XMLRotation = XMLNode->FirstChildElement("quaternion");
	quatRotation.x = Ogre::StringConverter::parseReal(XMLRotation->Attribute("x"));
	quatRotation.y = Ogre::StringConverter::parseReal(XMLRotation->Attribute("y"));
	quatRotation.z = Ogre::StringConverter::parseReal(XMLRotation->Attribute("z"));
	quatRotation.w = Ogre::StringConverter::parseReal(XMLRotation->Attribute("w"));
	//Debug text
	std::cout << "Quat: " << "qx: " << XMLRotation->Attribute("x");
	std::cout << "qy: " << XMLRotation->Attribute("y");
	std::cout << "qz: " << XMLRotation->Attribute("z");
	std::cout << "qw: " << XMLRotation->Attribute("w") << std::endl;

	//Get the scale
	XMLScale = XMLNode->FirstChildElement("scale");
	vec3Scale.x = Ogre::StringConverter::parseReal(XMLScale->Attribute("x"));
	vec3Scale.y = Ogre::StringConverter::parseReal(XMLScale->Attribute("y"));
	vec3Scale.z = Ogre::StringConverter::parseReal(XMLScale->Attribute("z")); 
	//Degub text
	std::cout << "Scale: " << "x: " << XMLScale->Attribute("x");
	std::cout << " y: " << XMLScale->Attribute("y");
	std::cout << " z: " << XMLScale->Attribute("z") << std::endl;



	//Get the entity
	XMLEntity = XMLNode->FirstChildElement("entity");
	meshName = XMLEntity->Attribute("name");
	meshFile = XMLEntity->Attribute("meshFile");
	std::cout << "meshname: " << meshName << " meshFile: " << meshFile << std::endl;

	//Create the entity
	ent = mvpSceneMgr->createEntity(meshName,meshFile);
	//if(Ogre::StringConverter::parseBool(XMLEntity->Attribute("castShadows")))
	ent->setCastShadows(false);
	//if(ent->getCastShadows())
	//	std::cout << "ent casts shadows"<< std::endl;
	std::cout << "nodeName + Node";
	Ogre::String str = nodeName;
	str += "Node";
	
	//vec3Position.y = mvpTerrain->getHeightAtWorldPosition(vec3Position);
	//vec3Position.y -= 0.3; //@todo wtf!
	Ogre::SceneNode *node = mvpSceneMgr->getRootSceneNode()->createChildSceneNode(str,vec3Position,quatRotation);
	std::cout << "createChildNode";
	node->scale(vec3Scale);
	std::cout << "scale";
	node->attachObject(ent);

	//Get physicsproperties
	std::vector<Ogre::Vector3> posList;

	TiXmlElement * XMLUserData = XMLNode->FirstChildElement("userData");
	XMLProperty = XMLUserData->FirstChildElement("property");
	bool EntityIsStatic = false;
	int collisionGroup;
	int mass  = 0;
	Ogre::String posString;
	Ogre::Vector3 tempVec(0,0,0);
	Ogre::Real speed;
	double tempDouble;
	while(XMLProperty)
	{
		Ogre::String propName = XMLProperty->Attribute("name");
		if (propName.compare("isStatic") == 0)
			if (Ogre::StringConverter::parseInt(XMLProperty->Attribute("data")) == 1)
				EntityIsStatic = true;

		if (propName.compare("mass") == 0)
			mass = Ogre::StringConverter::parseInt(XMLProperty->Attribute("data"));
					
		if(propName.compare("collisionGroup") == 0)
			collisionGroup = Ogre::StringConverter::parseInt(XMLProperty->Attribute("data"));

		if(propName.compare("position") == 0)
		{
			std::stringstream ost;
			posString = XMLProperty->Attribute("data");
			ost << posString;
			ost >> tempDouble;
			tempVec.x = tempDouble;
			ost >> tempDouble;
			tempVec.y = tempDouble;
			ost >> tempDouble;
			tempVec.z = tempDouble;
			posList.push_back(tempVec);
			ost.clear();
		}

		if(propName.compare("speed") == 0)
			speed = Ogre::StringConverter::parseReal(XMLProperty->Attribute("data"));
		
		XMLProperty = XMLProperty->NextSiblingElement("property");
	}
/********** routine de d�lacement **********/ 
void itsHybridContinuousInteractingAntColony::antMove( int antId )
{  
  printDebug( "antState", antState[0]);
  
  // si fourmi viens de faire un simplexe
  if ( antState[antId] == 0 ) {
    // re-placement al�toire :
    vector<double> aPoint;
    aPoint.reserve( this->getProblem()->getDimension() );
    
    
    // tirage al�toire uniforme sur l'hypercube de l'espace de recherche
    // aPoint = RandomVector_Cube( getBoundsMinima(), getBoundsMaxima() );
    
    // tirage al�toire dans la zone de visibilit�    //aPoint = RandomVector_Noise( antCurrentPoint[antId], antMoveRange[antId] );
    vector<double> tempVec( this->getProblem()->getDimension(),antMoveRange[antId] );
    aPoint = noiseUniform( antCurrentPoint[antId], tempVec );
    
    antMoveTo(antId, aPoint);
    
    // efface la pile de message
    vector<double> nullValuesStack;
    double nullValue = 0;
    nullValuesStack.push_back( nullValue );
    antIncomingValues[antId] =  nullValuesStack;
    
    vector< vector<double> > nullPointsStack;
    vector<double> nullPoint( this->getProblem()->getDimension(), 0 );
    nullPointsStack.push_back( nullPoint );
    antIncomingPoints[antId] = nullPointsStack;
    
    
    // fin de cet �at
    antState[antId]=0.0001;
    
    spotsEvaporate();
    return;
    
  } else { // fourmi n'as pas encore fait de simplexe
    // d�lacement normal
    
    // choix du d�lacement
    int ok=0;
    int choice;
    // si choix des spots
    choice = thresholdChoice( antProbaMemory[antId], probaUseMemoryThreshold, probaUseMemoryPower, 'e' );
    
    if ( choice  ) {
      ok += antMoveSpots( antId );
    } else { // choix des messages
      ok += antMoveMessages( antId );
    }
        
    // si d�lacement spots/message fait
    if ( ok > 0 ) {
      spotsEvaporate();
      return;
    }
    
    // teste motivation simplexe
    choice = thresholdChoice( antState[antId], probaUseNMSThreshold, probaUseNMSPower, 'e' );

    if ( choice ) {
      // intensification par simplexe
      ok += antMoveNMS(antId);
      // d�ot spot
      antSpotLay( antId, antCurrentPoint[antId], antCurrentValue[antId] );
      // a fait son intensification
      antState[antId] = 0;

    } else { // pas motiv� pour le simplexe
      // test envoi de message
      choice = thresholdChoice( 1 - antState[antId], probaUseNMSThreshold, probaUseNMSPower, 'e' );
      
      if ( choice ) {
        // envoi de message
        antMessageSend( antId, antMessageChooseMate(antId) );	
        // augmentation motivation
        antIncreaseState(antId);
      }
    }
    
    // si d�lacement simplexe impossible
    if ( ok == 0 ) {
      antMoveRandom( antId );
      spotsEvaporate();
      return;
    }
    
  }
  
  spotsEvaporate();
}