I changed my mind, draw references to fin aft end

This commit is contained in:
SiboVG 2023-07-21 22:03:16 +02:00
parent 970e709465
commit 933fc0cadf

View File

@ -297,24 +297,23 @@ public class FinMarkingGuide extends JPanel {
// Account for canted fins // Account for canted fins
/* /*
The arrow will be rotated around the fore base end of the fin. The arrow will be rotated around the aft base end of the fin.
This is because this gives the user an easy way to know where the fin should be positioned. This is because the aft end will most likely be at the aft end of the body tube.
Just position the fore end mark to where you want the fore end of the fin to be, then mark If we were to rotate around the fore end, there's a good chance that the marking guide
the two ends of the arrow, connect them and you have your fin position. extends beyond the body tube aft end and thus you cannot draw the arrow.
NOTE: the front/fore end of the rocket is drawn at the right.
*/ */
final double cantAngle = - fins.getCantAngle(); // Invert cant angle because the front end of the rocket is to the right final double cantAngle = - fins.getCantAngle(); // Invert cant angle because the front end of the rocket is to the right
final boolean isCanted = !MathUtil.equals(cantAngle, 0); final boolean isCanted = !MathUtil.equals(cantAngle, 0);
if (isCanted) { if (isCanted) {
// We want to end the arrow at the fore end of the fin, so we need add an offset to // We want to end the arrow at the aft end of the fin, so we need add an offset to
// the start to account for the y-shift of the fore end of the fin due to the cant. // the start to account for the y-shift of the aft end of the fin due to the cant.
final double finBaseHalfWidth = PrintUnit.METERS.toPoints(fins.getLength()) / 2; final double finBaseHalfWidth = PrintUnit.METERS.toPoints(fins.getLength()) / 2;
final int yFinForeEndOffset = (int) Math.round(finBaseHalfWidth * Math.sin(cantAngle)); final int yFinForeEndOffset = - (int) Math.round(finBaseHalfWidth * Math.sin(cantAngle));
yEnd = yFinCenter + yFinForeEndOffset; yStart = yFinCenter + yFinForeEndOffset;
// Calculate y offset of start point // Calculate y offset of end point
int yOffset = - (int) Math.round(width * Math.tan(cantAngle)); int yOffset = (int) Math.round(width * Math.tan(cantAngle));
yStart = yEnd + yOffset; yEnd = yStart + yOffset;
} else { } else {
yStart = yFinCenter; yStart = yFinCenter;
yEnd = yFinCenter; yEnd = yFinCenter;
@ -343,10 +342,10 @@ public class FinMarkingGuide extends JPanel {
g2.setStroke(dashedStroke); g2.setStroke(dashedStroke);
// Draw dashed line // Draw dashed line
// We draw from left to right to ensure that the side with no arrow // We draw from right to left to ensure that the side where the side does not touch
// point has the dashed line touching the marking guide edge // with an arrow point (fore end) has the dashed line touching the marking guide edge
// (is useful for marking the fin position) // (is useful for marking the fin position)
g2.drawLine(x, yEnd, x + width, yEnd); g2.drawLine(x + width, yStart, x, yStart);
// Reset stroke // Reset stroke
g2.setStroke(thinStroke); g2.setStroke(thinStroke);
@ -354,10 +353,10 @@ public class FinMarkingGuide extends JPanel {
//// -- Cross //// -- Cross
final double finBaseHalfWidth = PrintUnit.METERS.toPoints(fins.getLength()) / 2; final double finBaseHalfWidth = PrintUnit.METERS.toPoints(fins.getLength()) / 2;
// The cant also has an x-shift. We want the fore end to be perfectly flush with the // The cant also has an x-shift. We want the aft end to be perfectly flush with the
// right of the marking guide, so apply an x-shift to fin center position // left of the marking guide, so apply an x-shift to fin center position
int xFinCenter = x + width - (int) Math.round(finBaseHalfWidth); int xFinCenter = x + (int) Math.round(finBaseHalfWidth);
int xFinCenterOffset = (int) Math.round(finBaseHalfWidth * (1 - Math.cos(cantAngle))); int xFinCenterOffset = - (int) Math.round(finBaseHalfWidth * (1 - Math.cos(cantAngle)));
xFinCenter += xFinCenterOffset; xFinCenter += xFinCenterOffset;
// Draw a cross where the center of the fin should be // Draw a cross where the center of the fin should be