Skip to content

Commit

Permalink
Merge pull request #492 from teyrana/fix_387_offaxis_cp
Browse files Browse the repository at this point in the history
[fixes #387] Fixes one source of off-axis CP error
  • Loading branch information
wcravens committed Dec 8, 2018
2 parents 4bd3e4f + 51418e3 commit 5e3d801
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 11 additions & 6 deletions core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java
Expand Up @@ -202,15 +202,20 @@ private AerodynamicForces calculateAssemblyNonAxialForces( final RocketComponen
AerodynamicForces componentForces = new AerodynamicForces().zero();
calcObj.calculateNonaxialForces(conditions, componentForces, warnings);

Coordinate x_cp_comp = componentForces.getCP();
Coordinate x_cp_weighted = x_cp_comp.setWeight(x_cp_comp.weight);
Coordinate x_cp_absolute = component.toAbsolute(x_cp_weighted)[0];
componentForces.setCP(x_cp_absolute);
Coordinate cp_comp = componentForces.getCP();

Coordinate cp_weighted = cp_comp.setWeight(cp_comp.weight);
Coordinate cp_absolute = component.toAbsolute(cp_weighted)[0];
if(1 < component.getInstanceCount()) {
cp_absolute = cp_absolute.setY(0.);
}

componentForces.setCP(cp_absolute);
double CN_instanced = componentForces.getCN();
componentForces.setCm(CN_instanced * componentForces.getCP().x / conditions.getRefLength());

// if( 0.0001 < Math.abs(0 - componentForces.getCNa())){
// System.err.println(String.format("%s....Component.CNa: %g @ CPx: %g", indent, componentForces.getCNa(), componentForces.getCP().x));
// if( 0.0001 < Math.abs(componentForces.getCNa())){
// System.err.println(String.format("%s....Component.CNa: %g @ CP: %g, %g", indent, componentForces.getCNa(), componentForces.getCP().x, componentForces.getCP().y));
// }

assemblyForces.merge(componentForces);
Expand Down
Expand Up @@ -86,6 +86,7 @@ public void testCPSimpleDry() {

assertEquals(" Estes Alpha III CNa value is incorrect:", exp_cna, cp_calc.weight, EPSILON);
assertEquals(" Estes Alpha III cp x value is incorrect:", exp_cpx, cp_calc.x, EPSILON);
assertEquals(" Estes Alpha III cp x value is incorrect:", 0.0, cp_calc.y, EPSILON);
}

@Test
Expand Down

0 comments on commit 5e3d801

Please sign in to comment.