Backed out 2 changesets (bug 1931901) for causing build bustages in TelemetryScalar...
[gecko.git] / gfx / layers / AxisPhysicsMSDModel.h
blobe303450ff2b1a0f1a883a6a8f850775f63e3032d
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_layers_AxisPhysicsMSDModel_h
8 #define mozilla_layers_AxisPhysicsMSDModel_h
10 #include "AxisPhysicsModel.h"
12 namespace mozilla {
13 namespace layers {
15 /**
16 * AxisPhysicsMSDModel encapsulates a 1-dimensional MSD (Mass-Spring-Damper)
17 * model. A unit mass is assumed.
19 class AxisPhysicsMSDModel : public AxisPhysicsModel {
20 public:
21 AxisPhysicsMSDModel(double aInitialPosition, double aInitialDestination,
22 double aInitialVelocity, double aSpringConstant,
23 double aDampingRatio);
25 virtual ~AxisPhysicsMSDModel();
27 /**
28 * Gets the raw destination of this axis at this moment.
30 double GetDestination() const;
32 /**
33 * Sets the raw destination of this axis at this moment.
35 void SetDestination(double aDestination);
37 /**
38 * Returns true when the position is close to the destination and the
39 * velocity is low.
41 bool IsFinished(double aSmallestVisibleIncrement) const;
43 protected:
44 double Acceleration(const State& aState) override;
46 private:
47 /**
48 * mDestination represents the target position and the resting position of
49 * the simulated spring.
51 double mDestination;
53 /**
54 * Greater values of mSpringConstant result in a stiffer / stronger spring.
56 double mSpringConstant;
58 /**
59 * mSpringConstantSqrtTimesTwo is calculated from mSpringConstant to reduce
60 * calculations performed in the inner loop.
62 double mSpringConstantSqrtXTwo;
64 /**
65 * Damping Ratio: http://en.wikipedia.org/wiki/Damping_ratio
67 * When mDampingRatio < 1.0, this is an under damped system.
68 * - Overshoots destination and oscillates with the amplitude gradually
69 * decreasing to zero.
71 * When mDampingRatio == 1.0, this is a critically damped system.
72 * - Reaches destination as quickly as possible without oscillating.
74 * When mDampingRatio > 1.0, this is an over damped system.
75 * - Reaches destination (exponentially decays) without oscillating.
77 double mDampingRatio;
80 } // namespace layers
81 } // namespace mozilla
83 #endif