00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 }
00329
00330 #include "atom_algorithms.hpp"
00331
00332 #endif
00333
00334