void ConvertCoordsEuclidean2Spherical(const VectorType& euclideanCoord, VectorType& sphereCoord, VectorType center) { VectorType tmpEuclideanCoord = euclideanCoord - center; sphereCoord.x = tmpEuclideanCoord.Norm(); float thitaValue = tmpEuclideanCoord.z/sphereCoord.x; if ( thitaValue > 1 || thitaValue < -1 ) { cout<<"Warning : Invalid thitaValue :"<< thitaValue<<endl; thitaValue = thitaValue > 1 ? 1 : thitaValue; thitaValue = thitaValue <-1 ? -1 : thitaValue; } sphereCoord.y = acos(thitaValue); sphereCoord.z = atan2(tmpEuclideanCoord.y,tmpEuclideanCoord.x); }