Merged changes fixing NaN when computing fin CG.

This commit is contained in:
kruland2607 2012-10-05 13:00:56 -05:00
parent 9c3fce4517
commit 4d77c817d8
2 changed files with 4 additions and 4 deletions

View File

@ -440,7 +440,7 @@ public abstract class FinSet extends ExternalComponent {
double da = (y0 + y1) * (x1 - x0) / 2; double da = (y0 + y1) * (x1 - x0) / 2;
finArea += da; finArea += da;
if (Math.abs(y0 - y1) < 0.00001) { if (Math.abs(y0 + y1) < 0.00001) {
finCGx += (x0 + x1) / 2 * da; finCGx += (x0 + x1) / 2 * da;
finCGy += y0 / 2 * da; finCGy += y0 / 2 * da;
} else { } else {

View File

@ -119,13 +119,13 @@ public class FinSetTest extends BaseTestCase {
fins.setPoints(points); fins.setPoints(points);
Coordinate coords = fins.getCG(); Coordinate coords = fins.getCG();
assertEquals(3.0, fins.getFinArea(), 0.001); assertEquals(3.0, fins.getFinArea(), 0.001);
// FIXME - this computes NaN assertEquals(3.5/3.0, coords.x, 0.001);
//assertEquals(3.5/3.0, coords.x, 0.001); assertEquals(0.5/3.0, coords.y, 0.001);
//assertEquals(0.5/3.0, coords.y, 0.001);
} }
} }
@Test @Test
public void testFreeformConvert() { public void testFreeformConvert() {
testFreeformConvert(new TrapezoidFinSet()); testFreeformConvert(new TrapezoidFinSet());