add helper to specifically set a vector's length along it's direction

This commit is contained in:
Gered 2013-09-14 22:20:43 -04:00
parent 05dd4a1de0
commit 513eff7cb5

View file

@ -206,6 +206,13 @@ public final class MathHelpers {
result.z = desiredSize.z / originalSize.z; result.z = desiredSize.z / originalSize.z;
} }
public static void setLengthOf(Vector3 v, float length) {
float scaleFactor = length / v.len();
v.x = v.x * scaleFactor;
v.y = v.y * scaleFactor;
v.z = v.z * scaleFactor;
}
/** /**
* Basically the same as {@link com.badlogic.gdx.math.Intersector#getLowestPositiveRoot} except for the addition * Basically the same as {@link com.badlogic.gdx.math.Intersector#getLowestPositiveRoot} except for the addition
* of a parameter maxR which limits the maximum root value we accept. Anything over this will also result * of a parameter maxR which limits the maximum root value we accept. Anything over this will also result