diff --git a/src/Avalonia.Base/Utilities/SpringSolver.cs b/src/Avalonia.Base/Utilities/SpringSolver.cs
index c0ad7a9952..6a9e69d221 100644
--- a/src/Avalonia.Base/Utilities/SpringSolver.cs
+++ b/src/Avalonia.Base/Utilities/SpringSolver.cs
@@ -37,10 +37,55 @@ internal struct SpringSolver
private double m_A;
private double m_B;
- public SpringSolver(double mass, double stiffness, double damping, double initialVelocity)
+ ///
+ ///
+ ///
+ /// The time period.
+ /// The damping ratio.
+ ///
+ public SpringSolver(TimeSpan period, double zeta, double initialVelocity)
+ : this(
+ 2 * Math.PI / period.TotalSeconds,
+ zeta,
+ initialVelocity)
{
- m_w0 = Math.Sqrt(stiffness / mass);
- m_zeta = damping / (2 * Math.Sqrt(stiffness * mass));
+ // T is period
+ // T = 2 * PI * sqrt(m / k)
+ }
+
+ ///
+ ///
+ ///
+ /// The mass of the oscillating body.
+ /// The stiffness of the oscillated body (spring constant).
+ /// The actual damping.
+ /// The initial velocity.
+ public SpringSolver(double m, double k, double c, double initialVelocity)
+ : this(
+ Math.Sqrt(k / m), // ωn
+ c / (2 * Math.Sqrt(k * m)), // c / Cc
+ initialVelocity)
+ {
+ // Cc is critical damping coefficient
+ // Cc = 2 * Sqrt(k * m)
+ // Cc = 2 * m * wn
+ // Cc = 2 * m * Sqrt(k / m)
+
+ // ζ is damping ratio (Greek letter zeta)
+ // ζ = m_zeta = c / Cc
+ }
+
+ ///
+ ///
+ ///
+ /// The the natural frequency of the system [rad/s].
+ /// The damping ratio.
+ ///
+ public SpringSolver(double ωn, double zeta, double initialVelocity)
+ {
+ // ωn = sqrt(k / m)
+ m_w0 = ωn;
+ m_zeta = zeta;
if (m_zeta < 1) {
// Under-damped.