示例#1
0
        public static float GetValueAs(float value, SpeedUnit from, SpeedUnit unit)
        {
            if (System.Math.Abs(value) < 1e-3)
            {
                return(0);
            }

            if (unit.IsPace() && !from.IsPace() ||
                !unit.IsPace() && from.IsPace())
            {
                // convert between pace and speed
                return(Conversion[(int)unit] / (value * Conversion[(int)from]));
            }
            else
            {
                // spare conversion to the same unit
                return(from == unit ? value : value *Conversion[(int)from] / Conversion[(int)unit]);
            }
        }