Skip to content

Commit

Permalink
Refs #10039. Make Goniometer::getEulerAngles use Quat impl.
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Jeffery committed Aug 1, 2014
1 parent 85a6cbe commit 93d74f2
Showing 1 changed file with 1 addition and 35 deletions.
36 changes: 1 addition & 35 deletions Code/Mantid/Framework/Geometry/src/Instrument/Goniometer.cpp
Expand Up @@ -246,41 +246,7 @@ void Goniometer::makeUniversalGoniometer()
*/
std::vector<double> Goniometer::getEulerAngles(std::string convention)
{

std::string conv(convention);
//translate convention to three integers X=0, Y=1, Z=2
if (conv.length()!=3) throw std::invalid_argument("Wrong convention name (string length not 3)");
boost::to_upper(conv);
if (conv.find_first_not_of("XYZ")!=std::string::npos) throw std::invalid_argument("Wrong convention name (characters other than XYZ)");
if ((conv[0]==conv[1]) || (conv[2]==conv[1])) throw std::invalid_argument("Wrong convention name (repeated indices)");
boost::replace_all(conv,"X","0");
boost::replace_all(conv,"Y","1");
boost::replace_all(conv,"Z","2");
int first, second, last, TB, par01,par12;
std::stringstream s;
s<<conv[0]<<" "<<conv[1]<<" "<<conv[2];
s>>first>>second>>last;
TB=(first+second+last+9==3)?1:0;
par01=((second-first+9)%3==1)?1:-1;
par12=((last-second+9)%3==1)?1:-1;

std::vector<double> angles(3);
double s1,s2,s3,c1,c2,c3;
s3=(1.-TB-TB*par12)*R[(last+TB*par12+9)%3][(last-par12+9)%3];
c3=(TB-(1.-TB)*par12)*R[(last+TB*par12+9)%3][(last+par12+9)%3];
angles[2]=atan2(s3,c3)*rad2deg;
V3D axis3(0,0,0);
axis3[last]=1.;
DblMatrix Rm3(Quat(-angles[2],axis3).getRotation()),Rp;
Rp=R*Rm3;
s1=par01*Rp[(first-par01+9)%3][(first+par01+9)%3];
c1=Rp[second][second];
s2=par01*Rp[first][3-first-second];
c2=Rp[first][first];
angles[0]=atan2(s1,c1)*rad2deg;
angles[1]=atan2(s2,c2)*rad2deg;

return angles;
return Quat(getR()).getEulerAngles(convention);
}

/// Private function to recalculate the rotation matrix of the goniometer
Expand Down

0 comments on commit 93d74f2

Please sign in to comment.