/** * \file pca_based_rigid_fitting.cpp * \brief Fast Rigid fitting functionalities * * Copyright 2007-2013 IMP Inventors. All rights reserved. * */ #include #include #include #include #include #include #include #include #include #include IMPMULTIFIT_BEGIN_NAMESPACE em::FittingSolutions pca_based_rigid_fitting( core::RigidBody rb, Refiner *rb_refiner, em::DensityMap *em_map, Float threshold, FloatKey wei_key, algebra::PrincipalComponentAnalysis dens_pca_input) { ParticlesTemp ps = rb_refiner->get_refined(rb); return pca_based_rigid_fitting(ps, em_map,threshold,wei_key,dens_pca_input); } em::FittingSolutions pca_based_rigid_fitting( ParticlesTemp ps, em::DensityMap *em_map,Float threshold, FloatKey , algebra::PrincipalComponentAnalysis dens_pca_input) { //find the pca of the density algebra::PrincipalComponentAnalysis dens_pca; if (dens_pca_input != algebra::PrincipalComponentAnalysis()){ dens_pca=dens_pca_input; } else{ algebra::Vector3Ds dens_vecs = em::density2vectors(em_map,threshold); dens_pca = algebra::get_principal_components(dens_vecs); } //move the rigid body to the center of the map core::XYZs ps_xyz = core::XYZs(ps); algebra::Transformation3D move2center_trans = algebra::Transformation3D( algebra::get_identity_rotation_3d(), dens_pca.get_centroid()-core::get_centroid(core::XYZs(ps_xyz))); for(unsigned int i=0;iget_coordinates()); } algebra::PrincipalComponentAnalysis ps_pca = algebra::get_principal_components(ps_vecs); IMP_IF_LOG(VERBOSE) { IMP_LOG_VERBOSE("in pca_based_rigid_fitting, density PCA:"< &pca, std::ostream &out) { algebra::Vector3D v1,v2; out << "" << std::endl; algebra::Vector3D values= pca.get_principal_values(); algebra::Vector3Ds vectors= pca.get_principal_components(); algebra::Vector3D centroid= pca.get_centroid(); out<<""<" << std::endl; out << "" << std::endl; } for (unsigned int i=1;i<4;i++) { out << "" << std::endl; } out << "" << std::endl; } IMPMULTIFIT_END_NAMESPACE