From 84100ba74ce4317f6294ee1c423f4bd323988cf1 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Tue, 16 Aug 2022 00:54:48 +0200 Subject: [PATCH 1/5] Cleanup code --- .../net/sf/openrocket/gui/scalefigure/FinPointFigure.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/FinPointFigure.java b/swing/src/net/sf/openrocket/gui/scalefigure/FinPointFigure.java index d6a06bd2f..032085e54 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/FinPointFigure.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/FinPointFigure.java @@ -178,14 +178,15 @@ public class FinPointFigure extends AbstractScaleFigure { // vv in fin-frame == draw-frame vv final double xOffset = -xFinStart; final double yOffset = -body.getRadius(xFinStart); + final float length_m = (float)( body.getLength()); Path2D.Double bodyShape = new Path2D.Double(); // draw front-cap: bodyShape.moveTo( xOffset, yOffset); bodyShape.lineTo( xOffset, yOffset + body.getForeRadius()); - final float length_m = (float)( body.getLength()); - Point2D.Double cur = new Point2D.Double (); + // draw edge + Point2D.Double cur = new Point2D.Double(); for( double xBody = xResolution_m ; xBody < length_m; xBody += xResolution_m ){ // xBody is distance from front of parent body cur.x = xOffset + xBody; // offset from origin (front of fin) From d2b14e2a5d60567d7f7bb73401bf51b14a3d833e Mon Sep 17 00:00:00 2001 From: SiboVG Date: Thu, 18 Aug 2022 00:15:47 +0200 Subject: [PATCH 2/5] [#1227] Include root points in fin 3D view & export --- core/src/net/sf/openrocket/rocketcomponent/FinSet.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java index 79dc0c4a3..f96681335 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java @@ -1009,7 +1009,8 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona * but the minor performance hit is not worth the code complexity of dealing with. */ public Coordinate[] getFinPointsWithTab() { - return combineCurves(getFinPoints(), getTabPoints()); + Coordinate[] temp = combineCurves(getFinPoints(), getRootPoints()); + return combineCurves(temp, getTabPoints()); } @Override From 5df7f4f10db3a8e4b4bc9b58f4dce49f4a634898 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Thu, 18 Aug 2022 00:28:50 +0200 Subject: [PATCH 3/5] Include root points in fin tabs --- core/src/net/sf/openrocket/rocketcomponent/FinSet.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java index f96681335..630f53e7d 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java @@ -963,8 +963,10 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona MathUtil.equals(getTabLength(), 0)){ return new Coordinate[]{}; } + + Coordinate[] rootPoints = getRootPoints(); - final int pointCount = 5; + final int pointCount = 5 + rootPoints.length; Coordinate[] points = new Coordinate[pointCount]; final Coordinate finFront = this.getFinFront(); @@ -987,7 +989,10 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona points[1] = new Coordinate(xTabFront, yTabBottom ); points[2] = new Coordinate(xTabTrail, yTabBottom ); points[3] = new Coordinate(xTabTrail, yTabTrail); - points[4] = new Coordinate(xTabFront, yTabFront); + for (int i = 0; i < rootPoints.length; i++) { + points[i + 4] = rootPoints[rootPoints.length - 1 -i]; + } + points[pointCount - 1] = new Coordinate(xTabFront, yTabFront); return points; } From a7a73e99495b2283a566d22c8eef1354b4a5f4d3 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Thu, 18 Aug 2022 22:46:45 +0200 Subject: [PATCH 4/5] 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. From 5492029a6926c02fa6a504822069485450ed624a Mon Sep 17 00:00:00 2001 From: SiboVG Date: Thu, 18 Aug 2022 23:04:08 +0200 Subject: [PATCH 5/5] Fix finset print resolution --- core/src/net/sf/openrocket/rocketcomponent/FinSet.java | 5 +++-- swing/src/net/sf/openrocket/gui/print/PrintableFinSet.java | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java index 76831696d..065e84245 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java @@ -1244,7 +1244,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona // 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 (in meters) of each individual iteration + final double xWidth = 0.0025; // 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 @@ -1271,7 +1271,8 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona points[lastIndex] = points[lastIndex].setX(body.getLength()).setY(body.getAftRadius()); } - if( 0.0000001 < (Math.abs(xOffset) + Math.abs(yOffset))){ + // translate the points if needed + if ((Math.abs(xOffset) + Math.abs(yOffset)) > 0.0000001) { points = translatePoints(points, xOffset, yOffset); } diff --git a/swing/src/net/sf/openrocket/gui/print/PrintableFinSet.java b/swing/src/net/sf/openrocket/gui/print/PrintableFinSet.java index 60d35a005..59719b504 100644 --- a/swing/src/net/sf/openrocket/gui/print/PrintableFinSet.java +++ b/swing/src/net/sf/openrocket/gui/print/PrintableFinSet.java @@ -48,7 +48,7 @@ public class PrintableFinSet extends AbstractPrintable { Coordinate[] points = component.getFinPointsWithTab(); - polygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.length); + polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO, points.length); polygon.moveTo(0, 0); minX = 0; @@ -57,8 +57,8 @@ public class PrintableFinSet extends AbstractPrintable { int maxY = 0; for (Coordinate point : points) { - final long x = (long)PrintUnit.METERS.toPoints(point.x); - final long y = (long)PrintUnit.METERS.toPoints(point.y); + final float x = (float) PrintUnit.METERS.toPoints(point.x); + final float y = (float) PrintUnit.METERS.toPoints(point.y); minX = (int) Math.min(x, minX); minY = (int) Math.min(y, minY); maxX = (int) Math.max(x, maxX);