فهرست منبع

Math Tools Update

Add number value normalization and denormalization math tools
MackeyK24 8 سال پیش
والد
کامیت
d2a3a3336c
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);
+        }
     }