Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

atom_algorithms.h

Go to the documentation of this file.
00001 // -*- mode: c++; -*-
00002 //
00003 //The Biomolecule Toolkit (BTK) is a C++ library for use in the
00004 //modeling, analysis, and design of biological macromolecules.
00005 //Copyright (C) 2001, Tim Robertson <kid50@users.sourceforge.net>
00006 //
00007 //This program is free software; you can redistribute it and/or modify
00008 //it under the terms of the GNU Lesser General Public License as published
00009 //by the Free Software Foundation; either version 2.1 of the License, or (at
00010 //your option) any later version.
00011 //
00012 //This program is distributed in the hope that it will be useful,  but
00013 //WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 //Lesser General Public License for more details. 
00016 //
00017 //You should have received a copy of the GNU Lesser General Public License 
00018 //along with this program; if not, write to the Free Software Foundation, 
00019 //Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 
00030 
00031 #ifndef BTK_ATOM_ALGORITHMS_H
00032 #define BTK_ATOM_ALGORITHMS_H
00033 
00034 
00035 #include "atom.h"
00036 #include "atom_predicates.h"
00037 #include "linear_algebra.h"
00038 
00039 #include <boost/concept_check.hpp>
00040 
00041 
00042 namespace BTK {
00043   
00044 
00047 template <bool SelectValue, typename AtomIterator>
00048 void
00049 set_atom_selection(AtomIterator first,
00050                    AtomIterator last)
00051 {
00052   set_atom_selection<SelectValue>(first,last,is_any());
00053 }
00054 
00055 template <bool SelectValue, typename AtomIterator, typename UnaryPredicate>
00056 void
00057 set_atom_selection(AtomIterator first,
00058                    AtomIterator last,
00059        UnaryPredicate test)
00060 {
00061   for(; first!= last; ++first){
00062     if( test( *first ) ) first->set_is_selected(SelectValue);
00063   }
00064 }
00065 
00066 
00072 template <typename AtomIterator>
00073 void 
00074 translate(AtomIterator first,
00075           AtomIterator last,
00076           const BTKVector& T);
00077 
00078 
00082 
00083 
00098 
00099 template <typename AtomIterator>
00100 void 
00101 rotate(AtomIterator first,
00102        AtomIterator last,
00103        double phi,
00104        double theta,
00105        double psi,
00106        const BTKVector& fixed_point);
00107 
00108 
00109 template <typename AtomIterator>
00110 inline 
00111 void 
00112 rotate(AtomIterator first,
00113        AtomIterator last,
00114        double phi,
00115        double theta,
00116        double psi) 
00117 {
00118   rotate(first,last,phi,theta,psi,
00119          center_of_mass(first,last));
00120 }
00122 
00123 
00132 
00133 template <typename AtomIterator>
00134 void 
00135 rotate(AtomIterator first,
00136        AtomIterator last,
00137        const BTKVector& axis,
00138        double theta,
00139        const BTKVector& fixed_point);
00140 
00141 
00142 
00143 template <typename AtomIterator>
00144 inline 
00145 void 
00146 rotate(AtomIterator first,
00147        AtomIterator last,
00148        const BTKVector& axis,
00149        double theta) 
00150 {
00151   rotate(first,last,axis,theta,
00152          center_of_mass(first,last));
00153 }
00155 
00156 
00162 template <typename AtomIterator>
00163 void 
00164 rotate(AtomIterator first,
00165        AtomIterator last,
00166        const BTKMatrix& R);
00168 
00173 template <typename AtomIterator>
00174 void
00175 transform(AtomIterator first,
00176           AtomIterator last,
00177           const BTKMatrix& R,
00178           const BTKVector& T);
00179 
00180 
00183 
00184 
00190 template <typename AtomIterator>
00191 BTKVector 
00192 center_of_mass(AtomIterator first,
00193                AtomIterator last);
00194 
00200 template <typename AtomIterator>
00201 void 
00202 center(AtomIterator first,
00203        AtomIterator last);
00204 
00207 template <typename AtomIterator1,typename AtomIterator2>
00208 void 
00209 align_centers(AtomIterator1 fixed_first,
00210               AtomIterator1 fixed_last,
00211               AtomIterator2 align_first,
00212               AtomIterator2 align_last);
00214 
00218 template <typename AtomIterator>
00219 void 
00220 principal_axes(AtomIterator first,
00221                AtomIterator last,
00222                std::vector<EigenState>& axes,
00223                BTKVector& COM);
00224 
00225 
00230 template <typename AtomIterator1, typename AtomIterator2>
00231 double 
00232 get_trivial_rmsd(AtomIterator1 a1_first,
00233                  AtomIterator1 a1_last,
00234                  AtomIterator2 a2_first,
00235                  AtomIterator2 a2_last);
00236 
00237 
00240 
00241 
00247 template <typename AtomIterator1, typename AtomIterator2>
00248 double 
00249 get_rmsd(AtomIterator1 a1_first,
00250          AtomIterator1 a1_last,
00251          AtomIterator2 a2_first,
00252          AtomIterator2 a2_last);
00253 
00254 
00271 template <typename AtomIterator1, typename AtomIterator2>
00272 void 
00273 leastsquares_superposition(AtomIterator1 fixed_first,
00274                            AtomIterator1 fixed_last,
00275                            AtomIterator2 superimpose_first,
00276                            AtomIterator2 superimpose_last,
00277                            BTKMatrix& R,
00278                            BTKVector& T,
00279                            double& rmsd);
00280 
00288 template <typename AtomIterator1, typename AtomIterator2, typename AtomIterator3>
00289 void
00290 leastsquares_superposition(AtomIterator1 fixed_first,
00291                            AtomIterator1 fixed_last, 
00292                            AtomIterator2 superimpose_first,
00293                            AtomIterator2 superimpose_last,
00294                            AtomIterator3 transform_first,
00295                            AtomIterator3 transform_last,
00296                            double& rmsd);
00298 
00299 
00300 
00301 
00307 template <typename AtomType>
00308 struct atom_rotator : public std::unary_function<AtomType&,void> {
00309   
00310   BOOST_CLASS_REQUIRE2(AtomType, Atom, boost, ConvertibleConcept);
00311 
00312   atom_rotator(BTKMatrix& R,
00313                BTKVector& T) 
00314     : _R(R), _T(T) {}
00315 
00316   void 
00317   operator()(AtomType& x)
00318   { 
00319     x.set_position(prec_prod(_R,x.position())+_T); 
00320   }
00321 
00322 private:
00323   BTKMatrix _R;
00324   BTKVector _T;
00325 };
00326 
00327 
00328 } // namespace BTK
00329 
00330 #include "atom_algorithms.hpp"
00331 
00332 #endif
00333 
00334 

Generated on Wed Apr 14 00:43:16 2004 for BTK by doxygen 1.3.6