Example #1
0
        public static string ToSimplestForm(this float val)
        {
            bool   hasDecimal = !val.AboutEqual(Mathf.Round(val));
            string format     = hasDecimal ? "{0:n1}" : "{0:n0}";

            return(string.Format(format, val));
        }
Example #2
0
 /// <summary>
 /// Calculates the moment of inertia of a solid sphere (ball).
 /// </summary>
 /// <remarks>
 /// <code>
 /// => I = 2mr² ÷ 5
 /// </code>
 /// </remarks>
 /// <param name="m"></param>
 /// <param name="r"></param>
 /// <returns></returns>
 public static float MomentInertia(float m, float r = 1)
 {
     return(.4f * m * (r.AboutEqual(1) ? 1 : Mathf.Pow(r, 2)));
 }