8 #ifndef IMPATOM_SMOOTHING_FUNCTIONS_H
9 #define IMPATOM_SMOOTHING_FUNCTIONS_H
11 #include <IMP/atom/atom_config.h>
16 IMPATOM_BEGIN_NAMESPACE
40 virtual double operator()(
double score,
double distance)
const = 0;
47 double distance)
const = 0;
77 double min_distance_, max_distance_;
78 double value_prefactor_, deriv_prefactor_;
80 inline double get_value(
double distance)
const {
81 if (distance <= min_distance_) {
83 }
else if (distance > max_distance_) {
86 double d = max_distance_ - distance;
87 return value_prefactor_ * d * d * (max_distance_ + 2.0 * distance
88 - 3.0 * min_distance_);
92 inline double get_deriv(
double distance)
const {
93 if (distance <= min_distance_ || distance > max_distance_) {
96 return deriv_prefactor_ * (max_distance_ - distance)
97 * (min_distance_ - distance);
102 ForceSwitch(
double min_distance,
double max_distance)
103 : min_distance_(min_distance), max_distance_(max_distance) {
105 "max_distance should be greater than min_distance");
106 double dist_dif = max_distance - min_distance;
107 value_prefactor_ = 1.0 / (dist_dif * dist_dif * dist_dif);
108 deriv_prefactor_ = 6.0 * value_prefactor_;
112 double factor = get_value(distance);
113 return score * factor;
117 double factor = get_value(distance);
118 double deriv_factor = get_deriv(distance);
119 return std::make_pair(score * factor,
120 score * deriv_factor + deriv * factor);
127 IMPATOM_END_NAMESPACE