nit: don't store cp as a member variable

This commit is contained in:
Sean Rhea
2010-01-02 10:09:49 -05:00
parent 2fc4cf79b9
commit d09152e394

View File

@@ -32,14 +32,14 @@
class DanielsPoints : public RideMetric { class DanielsPoints : public RideMetric {
static const double K; static const double K;
double score, cp; double score;
void count(double secs, double watts) { void count(double secs, double watts, double cp) {
score += K * secs * pow(watts / cp, 4); score += K * secs * pow(watts / cp, 4);
} }
public: public:
DanielsPoints() : score(0.0), cp(0.0) {} DanielsPoints() : score(0.0) {}
QString symbol() const { return "daniels_points"; } QString symbol() const { return "daniels_points"; }
QString name() const { return QObject::tr("Daniels Points"); } QString name() const { return QObject::tr("Daniels Points"); }
QString units(bool) const { return ""; } QString units(bool) const { return ""; }
@@ -77,24 +77,24 @@ class DanielsPoints : public RideMetric {
double weighted = 0.0; double weighted = 0.0;
score = 0.0; score = 0.0;
cp = zones->getCP(zoneRange); double cp = zones->getCP(zoneRange);
foreach(const RideFilePoint *point, ride->dataPoints()) { foreach(const RideFilePoint *point, ride->dataPoints()) {
while ((weighted > NEGLIGIBLE) while ((weighted > NEGLIGIBLE)
&& (point->secs > lastSecs + secsDelta + EPSILON)) { && (point->secs > lastSecs + secsDelta + EPSILON)) {
weighted *= attenuation; weighted *= attenuation;
lastSecs += secsDelta; lastSecs += secsDelta;
count(secsDelta, weighted); count(secsDelta, weighted, cp);
} }
weighted *= attenuation; weighted *= attenuation;
weighted += sampleWeight * point->watts; weighted += sampleWeight * point->watts;
lastSecs = point->secs; lastSecs = point->secs;
count(secsDelta, weighted); count(secsDelta, weighted, cp);
} }
while (weighted > NEGLIGIBLE) { while (weighted > NEGLIGIBLE) {
weighted *= attenuation; weighted *= attenuation;
lastSecs += secsDelta; lastSecs += secsDelta;
count(secsDelta, weighted); count(secsDelta, weighted, cp);
} }
} }
void override(const QMap<QString,QString> &map) { void override(const QMap<QString,QString> &map) {