vector_math.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_MATH_VECTOR_MATH_HPP
00026 #define BTK_MATH_VECTOR_MATH_HPP
00027 
00028 #include <cmath>
00029 
00030 #include <btk/core/math/btk_vector.hpp>
00031 
00032 namespace BTK {
00033 namespace MATH {
00034 
00036 
00037 
00040 inline
00041 BTKVector &
00042 normalize(BTKVector & v)
00043 {
00044   v /= norm_2(v);
00045   return v;
00046 }
00047 
00053 inline double length(BTKVector const & v) { return norm_2(v); }
00054 
00056 inline
00057 BTKVector
00058 cross(BTKVector const & lhs,
00059       BTKVector const & rhs)
00060 {
00061   BTKVector temp;
00062 
00063   temp[0] = lhs[1] * rhs[2] - lhs[2] * rhs[1];
00064   temp[1] = lhs[2] * rhs[0] - lhs[0] * rhs[2];
00065   temp[2] = lhs[0] * rhs[1] - lhs[1] * rhs[0];
00066 
00067   return temp;
00068 }
00069 
00072 BTKVector
00073 project(BTKVector const & a,
00074         BTKVector const & b);
00075 
00078 BTKVector
00079 project_normal(BTKVector const & a,
00080                BTKVector const & b);
00081 
00083 inline
00084 double
00085 cosine_vector_angle(BTKVector const & v1,
00086                     BTKVector const & v2)
00087 {
00088   return (prec_inner_prod(v1,v2) / (norm_2(v1) * norm_2(v2)));
00089 }
00090 
00092 inline
00093 double
00094 vector_angle(BTKVector const & v1,
00095              BTKVector const & v2)
00096 {
00097   return acos(cosine_vector_angle(v1,v2));
00098 }
00099 
00105 double
00106 vector_dihedral(BTKVector const & v1,
00107                 BTKVector const & v2,
00108                 BTKVector const & v3);
00109 
00111 
00112 } // namespace MATH
00113 } // namespace BTK
00114 
00115 #endif // BTK_VECTOR_MATH_H

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