فهرست منبع

Merge pull request #2568 from MackeyK24/master

Math Tools Update
David Catuhe 8 سال پیش
والد
کامیت
824b417572
1فایلهای تغییر یافته به همراه14 افزوده شده و 0 حذف شده
  1. 14 0
      src/Math/babylon.math.ts

+ 14 - 0
src/Math/babylon.math.ts

@@ -68,6 +68,20 @@
         public static Repeat(value:number, length:number): number {
 			return value - Math.floor(value / length) * length;
         }
+
+        /**
+         * Normalize the value between 0.0 and 1.0 using min and max values
+         */
+        public static Normalize(value:number, min:number, max:number): number {
+            return (value - min) / (max - min);
+        }
+
+        /**
+         * Denormalize the value from 0.0 and 1.0 using min and max values
+         */
+        public static Denormalize(normalized:number, min:number, max:number): number {
+            return (normalized * (max - min) + min);
+        }
     }