Box2D.Common.MathUtils.Floor C# (CSharp) Method

Floor() public static method

public static Floor ( float x ) : int
x float
return int
        public static int Floor(float x)
        {
            if (Settings.FAST_MATH)
            {
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                int y = (int)x;
                if (x < 0 && x != y)
                {
                    y--;
                }
                return y;
            }
            else
            {
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                return (int)Math.Floor(x);
            }
        }

Usage Example

Beispiel #1
0
        public void Normalize()
        {
            float d = MathUtils.TWO_PI * MathUtils.Floor(A0 / MathUtils.TWO_PI);

            A0 -= d;
            A  -= d;
        }