From 0bf49226854ba1a8f1ec179a1d46801460dc90b7 Mon Sep 17 00:00:00 2001 From: Steven Oliver Date: Sat, 2 Apr 2016 17:24:15 -0400 Subject: [PATCH] Correct Miller twist calculation --- src/LibBalistica/Miller.vala | 4 ++-- test/LibBalistica/Miller.vala | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/LibBalistica/Miller.vala b/src/LibBalistica/Miller.vala index 2fbacaa..c4351a4 100644 --- a/src/LibBalistica/Miller.vala +++ b/src/LibBalistica/Miller.vala @@ -55,10 +55,10 @@ namespace LibBalistica{ * @return The calculated twist as a double */ public double calc_twist() { - double temp1 = Math.sqrt (30.0 * this.mass) ; + double temp1 = 30.0 * this.mass ; double temp2 = this.safe_value * Math.pow (this.diameter, 3) * this.length * (1.0 + Math.pow (this.length, 2)) ; - return temp1 / temp2 ; + return Math.sqrt (temp1 / temp2) * this.diameter ; } /** diff --git a/test/LibBalistica/Miller.vala b/test/LibBalistica/Miller.vala index a38f3da..ab58119 100644 --- a/test/LibBalistica/Miller.vala +++ b/test/LibBalistica/Miller.vala @@ -25,26 +25,26 @@ public class MillerTests : Balistica.TestCase { public virtual void test_calc_twist() { LibBalistica.Miller m = new LibBalistica.Miller () ; - m.diameter = 0.5 ; - m.length = 1.5 ; - m.mass = 1 ; + m.diameter = 0.308 ; + m.length = 3.83 ; + m.mass = 180 ; m.safe_value = 2 ; - assert (m.calc_twist () == 4.4941338051705939) ; + assert (m.calc_twist () == 12.086147286066234) ; m = new LibBalistica.Miller () ; - assert (m.calc_twist () == 1.3693063937629153) ; + assert (m.calc_twist () == 2.7386127875258306) ; } public virtual void test_calc_stability() { LibBalistica.Miller m = new LibBalistica.Miller () ; - m.diameter = 0.5 ; - m.length = 1.5 ; - m.mass = 1 ; + m.diameter = 0.308 ; + m.length = 3.83 ; + m.mass = 180 ; m.safe_value = 2 ; - assert (m.calc_stability () == 2.4375) ; + assert (m.calc_stability () == 21.0828132906055) ; m = new LibBalistica.Miller () ; - assert (m.calc_stability () == 8) ; + assert (m.calc_stability () == 2) ; } }