Skip to content
Snippets Groups Projects
Commit e1f3b216 authored by Gerardo Tauriello's avatar Gerardo Tauriello
Browse files

Inlined DihedralAngle and ensured Real-ops used for increased performance.

parent c7c58a09
No related branches found
No related tags found
No related merge requests found
...@@ -178,20 +178,6 @@ Mat3 AxisRotation(const Vec3& axis, Real angle) ...@@ -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, 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); 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) Real MinDistance(const Vec3List& l1, const Vec3List& l2)
{ {
......
...@@ -166,9 +166,16 @@ Mat3 DLLEXPORT_OST_GEOM AxisRotation(const Vec3& axis, Real angle); ...@@ -166,9 +166,16 @@ Mat3 DLLEXPORT_OST_GEOM AxisRotation(const Vec3& axis, Real angle);
/// The returned vector is of length 1 /// The returned vector is of length 1
Vec3 DLLEXPORT_OST_GEOM OrthogonalVector(const Vec3& axis); Vec3 DLLEXPORT_OST_GEOM OrthogonalVector(const Vec3& axis);
/// \brief Get dihedral angle for p1-p2-p3-p4
Real DLLEXPORT_OST_GEOM DihedralAngle(const Vec3& p1, const Vec3& p2, inline Real DihedralAngle(const Vec3& p1, const Vec3& p2,
const Vec3& p3, const Vec3&p4); 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 //! returns std::min of each component
inline Vec3 Min(const Vec3& v1, const Vec3& v2) inline Vec3 Min(const Vec3& v1, const Vec3& v2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment