/** Calculate unambiguous average dihedral angle (in degrees) by converting to * cartesian coords using x = cos(theta), y = sin(theta), and: * tan(avgtheta) = avgy / avgx = SUM[sin(theta)] / SUM[cos(theta)] * See Eq. 2 from Altis et al., J. Chem. Phys., 126 p. 244111 (2007). */ static double AvgCalc_Dih( DataSet_1D const& dsIn, ClusterDist::Cframes const& cframesIn, double& sumx, double& sumy ) { sumy = 0.0; sumx = 0.0; // TODO: Convert angles to radians prior to this call? for (ClusterDist::Cframes_it frm = cframesIn.begin(); frm != cframesIn.end(); ++frm) { double theta = dsIn.Dval( *frm ) * Constants::DEGRAD; sumy += sin( theta ); sumx += cos( theta ); } return atan2(sumy, sumx) * Constants::RADDEG; }
static double AvgCalc_Std( DataSet_1D const& dsIn, ClusterDist::Cframes const& cframesIn ) { double val = 0.0; for (ClusterDist::Cframes_it frm = cframesIn.begin(); frm != cframesIn.end(); ++frm) val += dsIn.Dval( *frm ); return (val / (double)cframesIn.size()); }