Break up the area/cg test cases and add some documentation describing

what they are doing.
This commit is contained in:
kruland2607 2012-10-06 21:03:08 -05:00
parent d8edf41355
commit ecac762940

View File

@ -22,9 +22,10 @@ import org.junit.Test;
public class FinSetTest extends BaseTestCase {
@Test
public void testCGComputation() throws Exception {
public void testTrapezoidCGComputation() {
{
// This is a simple square fin with sides of 1.0.
TrapezoidFinSet fins = new TrapezoidFinSet();
fins.setFinCount(1);
fins.setFinShape(1.0, 1.0, 0.0, 1.0, .005);
@ -36,6 +37,12 @@ public class FinSetTest extends BaseTestCase {
}
{
// This is a trapezoid. Height 1, root 1, tip 1/2 no sweep.
// It can be decomposed into a rectangle followed by a triangle
// +---+
// | \
// | \
// +------+
TrapezoidFinSet fins = new TrapezoidFinSet();
fins.setFinCount(1);
fins.setFinShape(1.0, 0.5, 0.0, 1.0, .005);
@ -46,8 +53,18 @@ public class FinSetTest extends BaseTestCase {
assertEquals(0.4444, coords.y, 0.001);
}
}
@Test
public void testFreeformCGComputation() throws Exception {
{
// This is the same shape as the previous TrapezoidFinSet.
// This is a trapezoid. Height 1, root 1, tip 1/2 no sweep.
// It can be decomposed into a rectangle followed by a triangle
// +---+
// | \
// | \
// +------+
FreeformFinSet fins = new FreeformFinSet();
fins.setFinCount(1);
Coordinate[] points = new Coordinate[] {
@ -64,7 +81,8 @@ public class FinSetTest extends BaseTestCase {
}
{
// Add some superfluous points which are on the outline but "far apart"
// This is the same trapezoid as previous free form, but it has
// some extra points along the lines.
FreeformFinSet fins = new FreeformFinSet();
fins.setFinCount(1);
Coordinate[] points = new Coordinate[] {
@ -84,7 +102,10 @@ public class FinSetTest extends BaseTestCase {
}
{
// add some points which are close
// This is the same trapezoid as previous free form, but it has
// some extra points which are very close to previous points.
// in particular for points 0 & 1,
// y0 + y1 is very small.
FreeformFinSet fins = new FreeformFinSet();
fins.setFinCount(1);
Coordinate[] points = new Coordinate[] {
@ -104,8 +125,29 @@ public class FinSetTest extends BaseTestCase {
assertEquals(0.4444, coords.y, 0.001);
}
{
// Different shaped figure. Two rectangles crafted so two pairs of points y_0 = - y_1
}
@Test
public void testFreeFormCGWithNegativeY() throws Exception {
// This particular fin shape is currently not allowed in OR since the y values are negative
// however, it is possible to convert RockSim files and end up with fins which
// have negative y values.
// A user submitted an ork file which could not be simulated because the fin
// was constructed on a tail cone. It so happened that for one pair of points
// y_n = - y_(n+1) which caused a divide by zero and resulted in CGx = NaN.
// This Fin set is constructed to have the same problem. It is a square and rectagle
// where the two trailing edge corners of the rectangle satisfy y_0 = -y_1
//
// +---------+
// | |
// | |
// +----+ |
// | |
// | |
// +----+
FreeformFinSet fins = new FreeformFinSet();
fins.setFinCount(1);
Coordinate[] points = new Coordinate[] {
@ -121,7 +163,6 @@ public class FinSetTest extends BaseTestCase {
assertEquals(3.0, fins.getFinArea(), 0.001);
assertEquals(3.5/3.0, coords.x, 0.001);
assertEquals(0.5/3.0, coords.y, 0.001);
}
}