From a7a73e99495b2283a566d22c8eef1354b4a5f4d3 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Thu, 18 Aug 2022 22:46:45 +0200 Subject: [PATCH] Documentation --- .../sf/openrocket/rocketcomponent/FinSet.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java index 630f53e7d..76831696d 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java @@ -1232,36 +1232,37 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona * @return points representing the mount's points */ private Coordinate[] getMountPoints(final double xStart, final double xEnd, final double xOffset, final double yOffset) { - if( null == parent){ + if (parent == null) { return new Coordinate[]{Coordinate.ZERO}; } - // for a simple bodies, one increment is perfectly accurate. + // for a simple body, one increment is perfectly accurate. int divisionCount = 1; - // cast-assert final SymmetricComponent body = (SymmetricComponent) getParent(); + final double intervalLength = xEnd - xStart; // for anything more complicated, increase the count: - if( ( body instanceof Transition) && ( ((Transition)body).getType() != Shape.CONICAL )){ - // the maximum precision to enforce when calculating the areas of fins ( especially on curved parent bodies) - final double xWidth = 0.005; // width of each individual iteration - divisionCount = (int)Math.ceil( (xEnd - xStart) / xWidth ); + if ((body instanceof Transition) && (((Transition)body).getType() != Shape.CONICAL)) { + // the maximum precision to enforce when calculating the areas of fins (especially on curved parent bodies) + final double xWidth = 0.005; // width (in meters) of each individual iteration + divisionCount = (int) Math.ceil(intervalLength / xWidth); // When creating body curves, don't create more than this many divisions. -- only relevant on very large components final int maximumBodyDivisionCount = 100; - divisionCount = Math.min( maximumBodyDivisionCount, divisionCount); + divisionCount = Math.min(maximumBodyDivisionCount, divisionCount); } - - final double intervalLength = xEnd - xStart; - double increment = (intervalLength)/divisionCount; - + + // Recalculate the x step increment, now with the (rounded) division count. + double xIncrement = intervalLength / divisionCount; + + // Create the points: step through the radius of the parent double xCur = xStart; Coordinate[] points = new Coordinate[divisionCount+1]; - for( int index = 0; index < points.length; index++){ - double yCur = body.getRadius( xCur ); - points[index]=new Coordinate( xCur, yCur); + for (int index = 0; index < points.length; index++) { + double yCur = body.getRadius(xCur); + points[index] = new Coordinate(xCur, yCur); - xCur += increment; + xCur += xIncrement; } // correct last point, if beyond a rounding error from body's end.