using System; using System.Collections; using System.Collections.Generic; public static class FloatExtensions { /// /// Refrence link: https://forum.unity.com/attachments/upload_2021-1-14_13-8-33-png.773578/ /// public static float Remap(this float from, float fromMin, float fromMax, float toMin, float toMax) { var fromAbs = from - fromMin; var fromMaxAbs = fromMax - fromMin; var normal = fromAbs / fromMaxAbs; var toMaxAbs = toMax - toMin; var toAbs = toMaxAbs * normal; var to = toAbs + toMin; return to; } /// /// Just clamps the value between two numbers (Easier to write) /// public static float Clamp(this float input, float min, float max) => Math.Clamp(input, min, max); }