16 #ifndef INCLUDED_numeric_deriv_dihedral_deriv_hh
17 #define INCLUDED_numeric_deriv_dihedral_deriv_hh
56 Vector
const f2 =
cross(v,w);
87 Real
const max_x( std::cos( small_angle ));
88 Real
const min_x( std::cos( big_angle ));
100 Real
const dthetaU_dx = -1 / sqrt( 1- x*x );
101 Real
const dtheta_dthetaU( theta < 0 ? -1 : 1 );
103 F1 *= dtheta_dthetaU * dthetaU_dx;
104 F2 *= dtheta_dthetaU * dthetaU_dx;
121 bool & colinearity_flag,
131 colinearity_flag =
false;
137 Vector v12(
cross( v1, v2 ));
138 Vector v23(
cross( v2, v3 ));
140 Real
const n12( v12.
length() );
141 Real
const n23( v23.
length() );
143 if ( n12 <
Real(1e-9) || n23 <
Real(1e-9) ) {
144 colinearity_flag =
true;
148 x =
dot( v12, v23 ) / ( n12 * n23 );
152 Real
const f(
Real(1.0) / ( n12 * n23 ) );
153 helper( p1, f * v2, v23 , F1, F2);
158 Real
const f(
Real(-1.0) * x / ( n12 * n12 ) );
159 helper( p1, f * v2, v12, F1, F2 );
200 Real
x( 0.0 );
bool colinearity;
202 if ( colinearity )
return;
220 bool & colinearity_flag,
232 colinearity_flag =
false;
238 Vector v12(
cross( v1, v2 ));
239 Vector v23(
cross( v2, v3 ));
241 Real
const n12( v12.
length() );
242 Real
const n23( v23.
length() );
244 if ( n12 <
Real(1e-9) || n23 <
Real(1e-9) ) {
245 colinearity_flag =
true;
249 x =
dot( v12, v23) / ( n12 * n23 );
264 Real
const f(
Real(-1.0)/ ( n12 * n23 ) );
265 helper( p2, f * v2, v23 , F1, F2);
269 Real
const f(
Real(-1.0)/ ( n12 * n23 ) );
270 helper( p2, f * v1, v23 , F1, F2);
274 Real
const f(
Real(1.0)/ ( n12 * n23 ) );
275 helper( p2, f * v3, v12 , F1, F2);
283 Real
const f( x / ( n12 * n12 ) );
284 helper( p2, f * v2, v12, F1, F2 );
288 Real
const f( x / ( n12 * n12 ) );
289 helper( p2, f * v1, v12, F1, F2 );
293 Real
const f(
Real(-1.0) * x / ( n23 * n23 ) );
294 helper( p2, f * v3, v23, F1, F2 );
326 Real
x( 0.0 );
bool colinearity;
328 if ( colinearity )
return;
void dihedral_radians(xyzVector< T > const &p1, xyzVector< T > const &p2, xyzVector< T > const &p3, xyzVector< T > const &p4, T &angle)
Dihedral (torsion) angle in radians: angle value passed.
cmplx w(cmplx z, double relerr)
#define ASSERT_ONLY(x)
Macro wrapper for paramters that used only indebug_assert(...) statments. Intended to supress 'unused...
Conversions between degrees and radians.
void dihedral_p1_cosine_deriv_first(xyzVector< P > const &p1, xyzVector< P > const &p2, xyzVector< P > const &p3, xyzVector< P > const &p4, P &x, bool &colinearity_flag, xyzVector< P > &F1, xyzVector< P > &F2)
The first half of the computation of the f1/f2 derivatives for an end point of a dihedral. The values in the output-parameter vectors F1 and F2 are overwritten. The cosine of the dihedral theta is returned in the output parameter x.
Value length() const
Length.
xyzVector: Fast (x,y,z)-coordinate numeric vector
T abs(T const &x)
std::abs( x ) == | x |
void dihedral_p2_cosine_deriv_first(xyzVector< P > const &p1, xyzVector< P > const &p2, xyzVector< P > const &p3, xyzVector< P > const &p4, P &x, bool &colinearity_flag, xyzVector< P > &F1, xyzVector< P > &F2)
The first half of the computation of the f1/f2 derivatives for a central point of a dihedral...
void helper(xyzVector< P > const &M, xyzVector< P > const &w, xyzVector< P > &F1, xyzVector< P > &F2)
xyzTriple< T > cross(xyzTriple< T > const &a, xyzTriple< T > const &b)
Cross product.
T radians(T const °rees)
Radians of degrees.
xyzVector and xyzMatrix functions
Fast (x,y,z)-coordinate numeric vector.
T arccos(T const x)
like std::acos but with range checking
void dihedral_p2_cosine_deriv(xyzVector< P > const &p1, xyzVector< P > const &p2, xyzVector< P > const &p3, xyzVector< P > const &p4, P &theta, xyzVector< P > &f1, xyzVector< P > &f2)
compute f1/f2 atom derivative vectors for one of the two middle points defining a dihedral angle for ...
void dihedral_p1_cosine_deriv(xyzVector< P > const &p1, xyzVector< P > const &p2, xyzVector< P > const &p3, xyzVector< P > const &p4, P &theta, xyzVector< P > &f1, xyzVector< P > &f2)
compute f1/f2 atom derivative vectors for one of the two end points defining a dihedral angle for som...
void dihedral_deriv_second(xyzVector< P > const &p1, xyzVector< P > const &p2, xyzVector< P > const &p3, xyzVector< P > const &p4, P x, P &theta, xyzVector< P > &F1, xyzVector< P > &F2)
Whether computing the f1/f2 derivatives for a function of a dihedral for the end points (p1 or p4) or...
T dot(Quaternion< T > const &q1, Quaternion< T > const &q2)
Dot product.