diff options
| author | Romain Guy <romainguy@android.com> | 2009-08-12 15:23:56 -0700 |
|---|---|---|
| committer | Romain Guy <romainguy@android.com> | 2009-08-12 15:23:56 -0700 |
| commit | e85c5aa67ea27f930b573c0c6662ef6bd6314d54 (patch) | |
| tree | c6a66ff65cb0506737e76561c3deaf8a7945c901 /core/java/android/util/MathUtils.java | |
| parent | b5a72b0e14aefb658695bed8d2b598b701abaf3d (diff) | |
Add norm() and map() to MathUtils.
Diffstat (limited to 'core/java/android/util/MathUtils.java')
| -rw-r--r-- | core/java/android/util/MathUtils.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/java/android/util/MathUtils.java b/core/java/android/util/MathUtils.java index c80d90f8699f..b35dd1eac0de 100644 --- a/core/java/android/util/MathUtils.java +++ b/core/java/android/util/MathUtils.java @@ -144,6 +144,14 @@ public final class MathUtils { return start + (stop - start) * amount; } + public static float norm(float start, float stop, float value) { + return (value - start) / (stop - start); + } + + public static float map(float minStart, float minStop, float maxStart, float maxStop, float value) { + return maxStart + (maxStart - maxStop) * ((value - minStart) / (minStop - minStart)); + } + public static int random(int howbig) { return (int) (sRandom.nextFloat() * howbig); } |
