diff --git a/modules/geom/src/vecmat3_op.cc b/modules/geom/src/vecmat3_op.cc index 3c5cbdea27e4da7b92180eb558856757aa5f535d..f476eca3098fcde019427da37960a0bf826f0933 100644 --- a/modules/geom/src/vecmat3_op.cc +++ b/modules/geom/src/vecmat3_op.cc @@ -178,20 +178,6 @@ Mat3 AxisRotation(const Vec3& axis, Real angle) xy-ca*xy+sa*z, yy+ca-ca*yy, yz-ca*yz-sa*x, xz-ca*xz-sa*y, yz-ca*yz+sa*x,zz+ca-ca*zz); } - - -Real DihedralAngle(const Vec3& p1, const Vec3& p2, const Vec3& p3, - const Vec3&p4) -{ - Vec3 r1=p2-p1; - Vec3 r2=p3-p2; - Vec3 r3=p4-p3; - Vec3 r12cross = Cross(r1, r2); - Vec3 r23cross = Cross(r2, r3); - return atan2(Dot(r1*Length(r2), r23cross), - Dot(r12cross, r23cross)); -} - Real MinDistance(const Vec3List& l1, const Vec3List& l2) { diff --git a/modules/geom/src/vecmat3_op.hh b/modules/geom/src/vecmat3_op.hh index fbaaec161b20ba7ddc9112c89bda93295a2ec407..d7762cccfe7240647b34049c257152d4ba67e17a 100644 --- a/modules/geom/src/vecmat3_op.hh +++ b/modules/geom/src/vecmat3_op.hh @@ -166,9 +166,16 @@ Mat3 DLLEXPORT_OST_GEOM AxisRotation(const Vec3& axis, Real angle); /// The returned vector is of length 1 Vec3 DLLEXPORT_OST_GEOM OrthogonalVector(const Vec3& axis); - -Real DLLEXPORT_OST_GEOM DihedralAngle(const Vec3& p1, const Vec3& p2, - const Vec3& p3, const Vec3&p4); +/// \brief Get dihedral angle for p1-p2-p3-p4 +inline Real DihedralAngle(const Vec3& p1, const Vec3& p2, + const Vec3& p3, const Vec3& p4) { + const Vec3 r1 = p2-p1; + const Vec3 r2 = p3-p2; + const Vec3 r3 = p4-p3; + const Vec3 r12cross = Cross(r1, r2); + const Vec3 r23cross = Cross(r2, r3); + return std::atan2(Dot(r1*Length(r2), r23cross), Dot(r12cross, r23cross)); +} //! returns std::min of each component inline Vec3 Min(const Vec3& v1, const Vec3& v2)