From e900e3884a6c7fd2c2f8a1fd9a1f4d01621a1b92 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Sat, 2 Mar 2024 13:34:45 -0800 Subject: [PATCH] CustomEllipsoid: add the getHalfExtents() method --- .../shapes/custom/CustomEllipsoid.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/MinieLibrary/src/test/java/com/github/stephengold/shapes/custom/CustomEllipsoid.java b/MinieLibrary/src/test/java/com/github/stephengold/shapes/custom/CustomEllipsoid.java index 05089c1c3..0ccae53f2 100644 --- a/MinieLibrary/src/test/java/com/github/stephengold/shapes/custom/CustomEllipsoid.java +++ b/MinieLibrary/src/test/java/com/github/stephengold/shapes/custom/CustomEllipsoid.java @@ -37,6 +37,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE import java.util.logging.Logger; import jme3utilities.Validate; import jme3utilities.math.MyMath; +import jme3utilities.math.MyVector3f; /** * A collision shape for an axis-aligned ellipsoid. @@ -150,6 +151,29 @@ public CustomEllipsoid(Vector3f halfExtents, float inertiaFactor) { setScale(scale); } // ************************************************************************* + // new methods exposed + + /** + * Copy the half extents of the ellipsoid. + * + * @param storeResult storage for the result (modified if not null) + * @return the unscaled half extent for each local axis (either storeResult + * or a new vector, not null, all components >0) + */ + public Vector3f getHalfExtents(Vector3f storeResult) { + assert MyVector3f.isAllPositive(unscaledHe) : unscaledHe; + + Vector3f result; + if (storeResult == null) { + result = unscaledHe.clone(); + } else { + result = storeResult.set(unscaledHe); + } + + return result; + + } + // ************************************************************************* // CustomConvexShape methods /**