From b7345f5c3cfd100246b02aabf42554e06ebcc88a Mon Sep 17 00:00:00 2001 From: Billy Olsen Date: Sun, 19 Apr 2020 19:15:54 -0700 Subject: [PATCH] Correctly calculate the maximum height for side view. When calculating the subject dimensions, use the height as the radius of the circle which intersects all four corners of the BoundingBox in the Y, Z plane for both the rear view and the side view. The rear view was already doing this, but it was non-obvious that the side view should also be using this to calculate the height. It becomes obvious if we think about a winged rocket, i.e. a rocket who's fins in the Z direction are larger than those in the Y direction. In this configuration, a height based off of the fins in along the Y-axis alone will result in a "Fit" scaling which encapuslates the Y-axis fins. However, rotating that rocket will move the larger wings (the Z-axis fins) into the view, but the height will not allow for the wings to draw properly on the screen. Thusly, using the radius from the circle intersecting the bounding box along the Y, Z plane will ensure that the widest point from the body will be able to fit within the side view, regardless of the rotation around the X axis. Signed-off-by: Billy Olsen --- .../src/net/sf/openrocket/gui/scalefigure/RocketFigure.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java index 5775390a1..188d70ad2 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java @@ -419,13 +419,14 @@ public class RocketFigure extends AbstractScaleFigure { protected void updateSubjectDimensions() { // calculate bounds, and store in class variables final BoundingBox bounds = rocket.getSelectedConfiguration().getBoundingBox(); + final double maxR = Math.max(Math.hypot(bounds.min.y, bounds.min.z), + Math.hypot(bounds.max.y, bounds.max.z)); switch (currentViewType) { case SideView: - subjectBounds_m = new Rectangle2D.Double(bounds.min.x, bounds.min.y, bounds.span().x, bounds.span().y); + subjectBounds_m = new Rectangle2D.Double(bounds.min.x, -maxR, bounds.span().x, 2 * maxR); break; case BackView: - final double maxR = Math.max(Math.hypot(bounds.min.y, bounds.min.z), Math.hypot(bounds.max.y, bounds.max.z)); subjectBounds_m = new Rectangle2D.Double(-maxR, -maxR, 2 * maxR, 2 * maxR); break; default: