properties.hpp

Go to the documentation of this file.
00001 // -*- mode: c++; indent-tabs-mode: nil; -*-
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) 2005-2006, Tim Robertson <kid50@users.sourceforge.net>,
00006 //                         Chris Saunders <ctsa@users.sourceforge.net>
00007 //
00008 //This program is free software; you can redistribute it and/or modify
00009 //it under the terms of the GNU Lesser General Public License as published
00010 //by the Free Software Foundation; either version 2.1 of the License, or (at
00011 //your option) any later version.
00012 //
00013 //This program is distributed in the hope that it will be useful,  but
00014 //WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 //Lesser General Public License for more details.
00017 //
00018 //You should have received a copy of the GNU Lesser General Public License
00019 //along with this program; if not, write to the Free Software Foundation,
00020 //Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00021 
00024 
00025 #ifndef BTK_ALGORITHMS_PROPERTIES_HPP
00026 #define BTK_ALGORITHMS_PROPERTIES_HPP
00027 
00028 #include <iterator>
00029 
00030 #include <btk/core/math/btk_vector.hpp>
00031 #include <btk/core/math/btk_matrix.hpp>
00032 #include <btk/core/math/linear_algebra.hpp>
00033 
00034 namespace BTK {
00035 namespace ALGORITHMS {
00036 
00044 
00045 
00050 template <typename AtomIterator>
00051 BTK::MATH::BTKVector
00052 geometric_center(AtomIterator begin,
00053                  AtomIterator end)
00054  {
00055    typedef typename std::iterator_traits<AtomIterator>::value_type InputT;
00056 
00057    BTK::MATH::BTKVector COM(0,0,0);
00058    unsigned N = 0;
00059    for(AtomIterator i=begin;i!=end;++i,++N){ COM += i->position(); }
00060 
00061    return COM/N;
00062  }
00063 
00064 // template <typename AtomIterator>
00065 // void
00066 // principal_axes(AtomIterator begin,
00067 //                AtomIterator end,
00068 //                std::vector<BTK::MATH::EigenState>& axes,
00069 //                BTK::MATH::BTKVector & center)
00070 //  {
00071 //    center = geometric_center(begin,end);
00072 
00073 //    BTK::MATH::BTKMatrix covar(3,3);
00074 //    covar.clear();
00075 
00076 //    for(AtomIterator i = begin; i != end; ++i){
00077 //      BTK::MATH::BTKVector tmp(i->position() - center);
00078 //      covar += outer_prod(tmp,tmp);
00079 //    }
00080 
00081 //    axes = diagonalize_symmetric(covar);
00082 //  }
00083 
00085 
00086 } // namespace ALGORITHMS
00087 } // namespace BTK
00088 
00089 #endif

Generated on Sun Jul 15 20:46:27 2007 for BTK Core by  doxygen 1.5.1