Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
distance_deriv.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file numeric/deriv/angle_deriv.hh
11 /// @brief inline function for computing f1/f2 derivatives for a function of a distance
12 /// @author Phil Bradley did all the hard work deriving the math represented here.
13 /// @author Andrew Leaver-Fay copy-and-pasted Phil's code into this file from
14 /// the AtomPairConstraint.cc file for general use.
15 
16 #ifndef INCLUDED_numeric_deriv_distance_deriv_hh
17 #define INCLUDED_numeric_deriv_distance_deriv_hh
18 
19 #include <numeric/xyzVector.hh>
20 
21 namespace numeric {
22 namespace deriv {
23 
24 /// @brief Compute the f1/f2 derivative vectors for point p1 for a function F of the
25 /// distance between p1 and p2. This function returns the distance which should
26 /// be used to evaluate dF_ddist. dF_ddist should then be multiplied into both
27 /// f1 and f2. The values of the output variables f1 and f2 are overwritten.
28 template < class P >
29 inline
30 void
32  xyzVector< P > const & p1,
33  xyzVector< P > const & p2,
34  P & distance,
35  xyzVector< P > & f1,
36  xyzVector< P > & f2
37 )
38 {
39  typedef P Real;
40 
41  f2 = p1 - p2;
42  distance = f2.length();
43  if ( distance != Real(0.0) ) {
44  Real const invd = Real(1.0) / distance;
45  f1 = p1.cross( p2 );
46  f1 *= invd;
47  f2 *= invd;
48  } else {
49  f1 = Real(0.0);
50  }
51 }
52 
53 
54 }
55 }
56 
57 #endif
Value length() const
Length.
Definition: xyzVector.hh:1638
xyzVector: Fast (x,y,z)-coordinate numeric vector
T distance(MathVector< T > const &VECTOR_A, MathVector< T > const &VECTOR_B)
double Real
Definition: types.hh:39
xyzVector cross(xyzVector const &v) const
Cross product.
Definition: xyzVector.hh:1203
void distance_f1_f2_deriv(xyzVector< P > const &p1, xyzVector< P > const &p2, P &distance, xyzVector< P > &f1, xyzVector< P > &f2)
Compute the f1/f2 derivative vectors for point p1 for a function F of the distance between p1 and p2...
Fast (x,y,z)-coordinate numeric vector.