Merge pull request #2214 from SiboVG/issue-2209
[#2209] Average segment centroids
This commit is contained in:
commit
b8895a1ea0
@ -544,7 +544,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
return centerOfMass;
|
||||
}
|
||||
|
||||
private static Coordinate calculateFilletCrossSection(final double filletRadius, final double bodyRadius){
|
||||
private static Coordinate calculateFilletCrossSection(final double filletRadius, final double bodyRadius) {
|
||||
final double hypotenuse = filletRadius + bodyRadius;
|
||||
final double innerArcAngle = Math.asin(filletRadius / hypotenuse);
|
||||
final double outerArcAngle = Math.acos(filletRadius / hypotenuse);
|
||||
@ -554,17 +554,17 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
- outerArcAngle * filletRadius * filletRadius / 2
|
||||
- innerArcAngle * bodyRadius * bodyRadius / 2);
|
||||
|
||||
if(Double.isNaN(crossSectionArea)) {
|
||||
if (Double.isNaN(crossSectionArea)) {
|
||||
crossSectionArea = 0.;
|
||||
}else {
|
||||
} else {
|
||||
// each fin has a fillet on each side
|
||||
crossSectionArea *= 2;
|
||||
}
|
||||
|
||||
// heuristic, relTo the body center
|
||||
double yCentroid = bodyRadius + filletRadius /5;
|
||||
double yCentroid = bodyRadius + filletRadius / 5;
|
||||
|
||||
return new Coordinate(0,yCentroid,0,crossSectionArea);
|
||||
return new Coordinate(0, yCentroid, 0, crossSectionArea);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -581,7 +581,8 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
* 5. Return twice that since there is a fillet on each side of the fin.
|
||||
*/
|
||||
protected Coordinate calculateFilletVolumeCentroid() {
|
||||
if((null == this.parent) || (!SymmetricComponent.class.isAssignableFrom(this.parent.getClass()))){
|
||||
if ((this.filletRadius == 0) || (this.parent == null) ||
|
||||
(!SymmetricComponent.class.isAssignableFrom(this.parent.getClass()))) {
|
||||
return Coordinate.ZERO;
|
||||
}
|
||||
Coordinate[] mountPoints = this.getRootPoints();
|
||||
@ -594,7 +595,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
final Coordinate finLead = getFinFront();
|
||||
final double xFinEnd = finLead.x + getLength();
|
||||
final Coordinate[] rootPoints = getMountPoints( finLead.x, xFinEnd, -finLead.x, -finLead.y);
|
||||
if (0 == rootPoints.length) {
|
||||
if (rootPoints.length == 0) {
|
||||
return Coordinate.ZERO;
|
||||
}
|
||||
|
||||
@ -616,7 +617,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
|
||||
final Coordinate segmentCentroid = segmentCrossSection.setWeight(segmentVolume);
|
||||
|
||||
filletVolumeCentroid = filletVolumeCentroid.add(segmentCentroid);
|
||||
filletVolumeCentroid = filletVolumeCentroid.average(segmentCentroid);
|
||||
|
||||
prev = cur;
|
||||
}
|
||||
@ -624,7 +625,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
if (finCount == 1) {
|
||||
Transformation rotation = Transformation.rotate_x( getAngleOffset());
|
||||
return rotation.transform(filletVolumeCentroid);
|
||||
}else{
|
||||
} else{
|
||||
return filletVolumeCentroid.setY(0.);
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,32 @@ public class TrapezoidFinSetTest extends BaseTestCase {
|
||||
return rkt;
|
||||
}
|
||||
|
||||
private Rocket createFreeformFinOnTransition() {
|
||||
final Rocket rkt = new Rocket();
|
||||
final AxialStage stg = new AxialStage();
|
||||
rkt.addChild(stg);
|
||||
Transition transition = new Transition();
|
||||
transition.setLength(0.2);
|
||||
transition.setForeRadius(0.1);
|
||||
transition.setAftRadius(0.3);
|
||||
transition.setShapeType(Transition.Shape.OGIVE);
|
||||
stg.addChild(transition);
|
||||
FreeformFinSet fins = new FreeformFinSet();
|
||||
fins.setFinCount(1);
|
||||
fins.setAxialOffset(AxialMethod.MIDDLE, 0.0);
|
||||
fins.setMaterial(Material.newMaterial(Material.Type.BULK, "Fin-Test-Material", 1.0, true));
|
||||
fins.setThickness(0.005); // == 5 mm
|
||||
|
||||
transition.addChild(fins);
|
||||
|
||||
fins.setTabLength(0.00);
|
||||
|
||||
fins.setFilletRadius(0.0);
|
||||
|
||||
rkt.enableEvents();
|
||||
return rkt;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiplicity() {
|
||||
final TrapezoidFinSet trapFins = new TrapezoidFinSet();
|
||||
@ -187,6 +213,33 @@ public class TrapezoidFinSetTest extends BaseTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilletCalculationsOnTransition() {
|
||||
final Rocket rkt = createFreeformFinOnTransition();
|
||||
Transition transition = (Transition) rkt.getChild(0).getChild(0);
|
||||
FinSet fins = (FinSet) rkt.getChild(0).getChild(0).getChild(0);
|
||||
|
||||
fins.setFilletRadius(0.005);
|
||||
fins.setFilletMaterial(Material.newMaterial(Material.Type.BULK, "Fillet-Test-Material", 1.0, true));
|
||||
|
||||
// used for fillet and edge calculations:
|
||||
//
|
||||
// [1] +--+ [2]
|
||||
// / \
|
||||
// / \
|
||||
// [0] +--------+ [3]
|
||||
//
|
||||
assertEquals(0.05, fins.getLength(), EPSILON);
|
||||
assertEquals("Transition fore radius doesn't match: ", 0.1, transition.getForeRadius(), EPSILON);
|
||||
assertEquals("Transition aft radius doesn't match: ", 0.3, transition.getAftRadius(), EPSILON);
|
||||
|
||||
final Coordinate actVolume = fins.calculateFilletVolumeCentroid();
|
||||
|
||||
assertEquals("Fin volume doesn't match: ", 5.973e-07, actVolume.weight, EPSILON);
|
||||
assertEquals("Fin mass center.x doesn't match: ", 0.024393025, actVolume.x, EPSILON);
|
||||
assertEquals("Fin mass center.y doesn't match: ", 0.190479957, actVolume.y, EPSILON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrapezoidCGComputation() {
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user