Merge pull request #1641 from SiboVG/issue-1639
[#1639] Take negative y fin points into account for back view
This commit is contained in:
commit
3d40d5e079
@ -7,6 +7,7 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
import net.sf.openrocket.rocketcomponent.FinSet;
|
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
|
import net.sf.openrocket.rocketcomponent.SymmetricComponent;
|
||||||
import net.sf.openrocket.util.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
import net.sf.openrocket.util.MathUtil;
|
import net.sf.openrocket.util.MathUtil;
|
||||||
import net.sf.openrocket.util.Transformation;
|
import net.sf.openrocket.util.Transformation;
|
||||||
@ -106,15 +107,20 @@ public class FinSetShapes extends RocketComponentShape {
|
|||||||
cTab[2]=new Coordinate(0, -tabHeight,thickness/2);
|
cTab[2]=new Coordinate(0, -tabHeight,thickness/2);
|
||||||
cTab[3]=new Coordinate(0, -tabHeight,-thickness/2);
|
cTab[3]=new Coordinate(0, -tabHeight,-thickness/2);
|
||||||
|
|
||||||
// Apply base rotation
|
// y translate the back view (if there is a fin point with non-zero y value)
|
||||||
c = transformation.transform(c);
|
Coordinate[] points = finset.getFinPoints();
|
||||||
cTab = transformation.transform(cTab);
|
double yOffset = Double.MAX_VALUE;
|
||||||
|
for (Coordinate point : points) {
|
||||||
|
yOffset = MathUtil.min(yOffset, point.y);
|
||||||
|
}
|
||||||
|
final Transformation translateOffsetY = new Transformation(0, yOffset, 0);
|
||||||
|
final Transformation compositeTransform = transformation.applyTransformation(translateOffsetY);
|
||||||
|
|
||||||
// Make polygon
|
// Make polygon
|
||||||
Path2D.Double p = createUncantedPolygon(c);
|
Shape p = makePolygonBack(c, compositeTransform);
|
||||||
|
|
||||||
if (tabHeight != 0 && finset.getTabLength() != 0) {
|
if (tabHeight != 0 && finset.getTabLength() != 0) {
|
||||||
Path2D.Double pTab = createUncantedPolygon(cTab);
|
Shape pTab = makePolygonBack(cTab, compositeTransform);
|
||||||
return new Shape[]{p, pTab};
|
return new Shape[]{p, pTab};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -122,22 +128,6 @@ public class FinSetShapes extends RocketComponentShape {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Path2D.Double createUncantedPolygon(Coordinate[] c) {
|
|
||||||
Coordinate a;
|
|
||||||
Path2D.Double p = new Path2D.Double();
|
|
||||||
|
|
||||||
a = c[0];
|
|
||||||
p.moveTo(a.z, a.y);
|
|
||||||
a = c[1];
|
|
||||||
p.lineTo(a.z, a.y);
|
|
||||||
a = c[2];
|
|
||||||
p.lineTo(a.z, a.y);
|
|
||||||
a = c[3];
|
|
||||||
p.lineTo(a.z, a.y);
|
|
||||||
p.closePath();
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Shape[] cantedShapesBack(FinSet finset,
|
private static Shape[] cantedShapesBack(FinSet finset,
|
||||||
Transformation transformation) {
|
Transformation transformation) {
|
||||||
if (finset.getTabHeight() == 0 || finset.getTabLength() == 0) {
|
if (finset.getTabHeight() == 0 || finset.getTabLength() == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user