diff --git a/modules/geom/pymod/export_vec3.cc b/modules/geom/pymod/export_vec3.cc index 2eaa7083b831538d5dc491c0fdd94ef0242f1a65..7691c59ac0090a17a0aa79394ac24aada3686eb8 100644 --- a/modules/geom/pymod/export_vec3.cc +++ b/modules/geom/pymod/export_vec3.cc @@ -126,5 +126,6 @@ void export_Vec3() .def("GetRMSD", &Vec3List::GetRMSD,(arg("other"))) .def("GetGDTHA", &Vec3List::GetGDTHA, (arg("other"), arg("norm")=true)) .def("GetGDTTS", &Vec3List::GetGDTTS, (arg("other"), arg("norm")=true)) + .def("GetGDT", &Vec3List::GetGDT, (arg("other"), arg("thresh"), arg("norm")=true)) ; } diff --git a/modules/geom/src/vec3.cc b/modules/geom/src/vec3.cc index bfc40cd1ebb6b76ccd9679bba19f48ec93434900..0adbc1a65d2ab414234ca9769374fe066cf9bbd2 100644 --- a/modules/geom/src/vec3.cc +++ b/modules/geom/src/vec3.cc @@ -181,6 +181,23 @@ Real Vec3List::GetGDTTS(const Vec3List& other, bool norm) const return norm && !this->empty() ? static_cast<Real>(n)/(this->size()*4) : n; } +Real Vec3List::GetGDT(const Vec3List& other, Real thresh, bool norm) const +{ + if(this->size() != other.size()) { + String m = "Inconsistent sizes in Vec3List::GetNWithin"; + throw GeomException(m); + } + int n = 0; + Real squared_thresh = thresh * thresh; + for(uint i = 0; i < this->size(); ++i) { + Real squared_d = geom::Length2((*this)[i] - other[i]); + if(squared_d < squared_thresh) { + ++n; + } + } + return norm && !this->empty() ? static_cast<Real>(n)/(this->size()) : n; +} + std::pair<Line3, Real> Vec3List::FitCylinder(const Vec3& initial_direction) const { Vec3 center=this->GetCenter(); diff --git a/modules/geom/src/vec3.hh b/modules/geom/src/vec3.hh index 5d45368009e1db8b5cee9293163cd1fadc7c4a2e..8302729061277c0bc5f9fa0b3d20caca36aaaa66 100644 --- a/modules/geom/src/vec3.hh +++ b/modules/geom/src/vec3.hh @@ -342,6 +342,7 @@ public: Real GetRMSD(const Vec3List& other) const; Real GetGDTHA(const Vec3List& other, bool norm=true) const; Real GetGDTTS(const Vec3List& other, bool norm=true) const; + Real GetGDT(const Vec3List& other, Real thresh, bool norm=true) const; //This function fits a cylinder to the positions in Vec3List //It takes as argument an initial guess for the direction.