Skip to content

Commit

Permalink
Correct Miller twist calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
steveno committed Apr 2, 2016
1 parent 0fb0885 commit 0bf4922
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/LibBalistica/Miller.vala
Expand Up @@ -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 ;
}

/**
Expand Down
20 changes: 10 additions & 10 deletions test/LibBalistica/Miller.vala
Expand Up @@ -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) ;
}

}

0 comments on commit 0bf4922

Please sign in to comment.