From 20ec790c5673e225a87f61cf92a2569f94afa6f6 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Wed, 8 Jun 2022 11:53:09 +0200 Subject: [PATCH 1/2] [#1351] Include ymin in 3D figure bounding box calculation --- swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java b/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java index 76c29cc4a..df2b50186 100644 --- a/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java +++ b/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java @@ -517,7 +517,7 @@ public class RocketFigure3d extends JPanel implements GLEventListener { // Add 10% for space around it. final double dX = (b.span().x * 1.2 / 2.0) / Math.tan(Math.toRadians(fovX / 2.0)); - final double dY = (b.span().y * 1.2 / 2.0) + final double dY = ((b.span().y - b.min.y) * 1.2 / 2.0) / Math.tan(Math.toRadians(fovY / 2.0)); // Move back the greater of the 2 distances From f77578c5c70a2e74ef4d27761c07c9fd7d28d76f Mon Sep 17 00:00:00 2001 From: SiboVG Date: Thu, 9 Jun 2022 20:52:10 +0200 Subject: [PATCH 2/2] Base 3D view zoom on maximum radius --- swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java b/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java index df2b50186..738d02270 100644 --- a/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java +++ b/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java @@ -515,9 +515,11 @@ public class RocketFigure3d extends JPanel implements GLEventListener { // Calculate the distance needed to fit the bounds in both the X and Y // direction // Add 10% for space around it. + final double maxR = Math.max( Math.hypot(b.min.y, b.min.z), + Math.hypot(b.max.y, b.max.z)); final double dX = (b.span().x * 1.2 / 2.0) / Math.tan(Math.toRadians(fovX / 2.0)); - final double dY = ((b.span().y - b.min.y) * 1.2 / 2.0) + final double dY = (2*maxR * 1.2 / 2.0) / Math.tan(Math.toRadians(fovY / 2.0)); // Move back the greater of the 2 distances