/** * \file RegistrationResult.cpp * \brief Registration results class * Copyright 2007-2010 IMP Inventors. All rights reserved. **/ #include "IMP/em2d/RegistrationResult.h" #include "IMP/em2d/internal/rotation_helper.h" IMPEM2D_BEGIN_NAMESPACE RegistrationResult::~RegistrationResult() {}; RegistrationResults get_random_registration_results(unsigned long n, double maximum_shift) { srand (time(NULL)); RegistrationResults results; for (unsigned long i=0;iR_=R; algebra::Vector3D angles= em2d::internal::get_euler_angles_from_rotation(R,3,2); this->phi_ = angles[0]; this->theta_=angles[1]; this->psi_=angles[2]; } void RegistrationResult::read(const String &line) { algebra::VectorD<4> quaternion; String s = line; size_t n; n=s.find("|"); index_=std::atoi(s.substr(0,n).c_str()); s=s.substr(n+1); n=s.find("|"); phi_ =std::atof(s.substr(0,n).c_str()); s=s.substr(n+1); n=s.find("|"); theta_ =std::atof(s.substr(0,n).c_str()); s=s.substr(n+1); n=s.find("|"); psi_ =std::atof(s.substr(0,n).c_str()); s=s.substr(n+1); n=s.find("|"); quaternion[0] =std::atof(s.substr(0,n).c_str()); s=s.substr(n+1); n=s.find("|"); quaternion[1] =std::atof(s.substr(0,n).c_str()); s=s.substr(n+1); n=s.find("|"); quaternion[2] =std::atof(s.substr(0,n).c_str()); s=s.substr(n+1); n=s.find("|"); quaternion[3] =std::atof(s.substr(0,n).c_str()); s=s.substr(n+1); n=s.find("|"); shift_[0] =std::atof(s.substr(0,n).c_str()); s=s.substr(n+1); n=s.find("|"); shift_[1] =std::atof(s.substr(0,n).c_str()); s=s.substr(n+1); n=s.find("|"); ccc_ =std::atof(s.substr(0,n).c_str()); set_rotation(phi_,theta_,psi_); } //! Reads a set of registration results RegistrationResults read_registration_results(String filename) { std::ifstream in(filename.c_str(),std::ios::in | std::ios::binary); unsigned int n_records=0; String line; while(!in.eof()) { getline(in,line); if(line[0]=='#') { continue; } else { n_records=std::atoi(line.c_str()); break; } } RegistrationResults results(n_records); for(unsigned int i=0;i= rr2.get_ccc()) return true; return false; } RegistrationResult::RegistrationResult() { shift_[0]=0.0; shift_[1]=0.0; ccc_=0.0; name_=""; index_=0; set_rotation(0,0,0); } RegistrationResult::RegistrationResult(algebra::Rotation3D &R, algebra::Vector2D &shift,long index,double ccc,String name) { shift_[0]=shift[0]; shift_[1]=shift[1]; ccc_=ccc; name_=name; index_=index; set_rotation(R); } RegistrationResult::RegistrationResult( double phi,double theta,double psi,double shift_x, double shift_y,long index,double ccc,String name) { IMP_LOG(IMP::VERBOSE," initialzing RegistrationResult " << std::endl); shift_[0]=shift_x; shift_[1]=shift_y; ccc_=ccc; name_=name; index_=index; set_rotation(phi,theta,psi); IMP_LOG(IMP::VERBOSE," end init RegistrationResult " << std::endl); } void RegistrationResult::show(std::ostream& out) const { algebra::VectorD<4> quaternion=R_.get_quaternion(); out << "Name: " << get_name() << " Index: " << get_index() << " (Phi,Theta,Psi) = ( " << phi_ << " , " << theta_ << " , " << psi_ << " ) | Shift (x,y) " << get_shift() << " CCC = " << get_ccc() << " Quaternion " << quaternion; } //! Writes a result line to a file void RegistrationResult::write(std::ostream& out) const { algebra::VectorD<4> quaternion=R_.get_quaternion(); char c='|'; out << get_index() <