From 1823fdd8d7feb1b2fccb337abda86b818f4556ae Mon Sep 17 00:00:00 2001 From: gered Date: Tue, 16 Jul 2013 15:33:08 -0400 Subject: [PATCH] add some bounding volume "to/from scale factor" helper methods --- src/com/blarg/gdx/math/MathHelpers.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/com/blarg/gdx/math/MathHelpers.java b/src/com/blarg/gdx/math/MathHelpers.java index 0a639fe..22c0304 100644 --- a/src/com/blarg/gdx/math/MathHelpers.java +++ b/src/com/blarg/gdx/math/MathHelpers.java @@ -3,6 +3,7 @@ package com.blarg.gdx.math; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; +import com.badlogic.gdx.math.collision.BoundingBox; public final class MathHelpers { static final Vector2 v2tmpA = new Vector2(); @@ -162,6 +163,16 @@ public final class MathHelpers { return lerp(low, high, (n * n) * (3.0f - (2.0f * n))); } + public static void getScaleFactor(BoundingBox originalSize, BoundingBox desiredSize, Vector3 result) { + getScaleFactor(originalSize.getDimensions(), desiredSize.getDimensions(), result); + } + + public static void getScaleFactor(Vector3 originalSize, Vector3 desiredSize, Vector3 result) { + result.x = desiredSize.x / originalSize.x; + result.y = desiredSize.y / originalSize.y; + result.z = desiredSize.z / originalSize.z; + } + // convenience overloads that should not really be used except in non-performance-critical situations public static Vector2 getDirectionVector2(float degrees) {