From c59660e4ac7518da2ce20cd89c9a2b37cd8c3a8c Mon Sep 17 00:00:00 2001 From: SiboVG Date: Thu, 24 Nov 2022 17:16:00 +0100 Subject: [PATCH] Add unit tests for pods bounding box --- .../rocketcomponent/BoundingBoxTest.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/core/test/net/sf/openrocket/rocketcomponent/BoundingBoxTest.java b/core/test/net/sf/openrocket/rocketcomponent/BoundingBoxTest.java index 8394a3dfb..21b6e3c09 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/BoundingBoxTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/BoundingBoxTest.java @@ -102,4 +102,37 @@ public class BoundingBoxTest extends BaseTestCase { assertEquals( 0.12069451, bounds.max.z, EPSILON); } + @Test + public void testPodsBoundingBox() { + Rocket rocket = TestRockets.makeEndPlateRocket(); + + // DEBUG + System.err.println(rocket.toDebugTree()); + + BoundingBox bounds = rocket.getBoundingBox(); + assertEquals( 0.0, bounds.min.x, EPSILON); + assertEquals( 0.304, bounds.max.x, EPSILON); + + assertEquals( -0.0365, bounds.min.y, EPSILON); + assertEquals( 0.0365, bounds.max.y, EPSILON); + + assertEquals( -0.0365, bounds.min.z, EPSILON); + assertEquals( 0.0365, bounds.max.z, EPSILON); + + // Add a mass component to the pod set (to test GitHub issue #1849) + PodSet podSet = (PodSet) rocket.getChild(0).getChild(1).getChild(1); + BodyTube tube = (BodyTube) podSet.getChild(0); + tube.addChild(new MassComponent()); + + bounds = rocket.getBoundingBox(); + assertEquals( 0.0, bounds.min.x, EPSILON); + assertEquals( 0.304, bounds.max.x, EPSILON); + + assertEquals( -0.0365, bounds.min.y, EPSILON); + assertEquals( 0.0365, bounds.max.y, EPSILON); + + assertEquals( -0.0365, bounds.min.z, EPSILON); + assertEquals( 0.0365, bounds.max.z, EPSILON); + } + }