Box2D.Common.MathUtils.Cos C# (CSharp) Метод

Cos() публичный статический Метод

public static Cos ( float x ) : float
x float
Результат float
        public static float Cos(float x)
        {
            if (Settings.SINCOS_LUT_ENABLED)
            {
                x %= TWO_PI;

                while (x < 0)
                {
                    x += TWO_PI;
                }

                if (Settings.SINCOS_LUT_LERP)
                {

                    x /= Settings.SINCOS_LUT_PRECISION;

                    //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 index = (int)x;

                    if (index != 0)
                    {
                        x %= index;
                    }

                    // the next index is 0
                    if (index == Settings.SINCOS_LUT_LENGTH - 1)
                    {
                        return ((1 - x) * COS_LUT[index] + x * COS_LUT[0]);
                    }
                    else
                    {
                        return ((1 - x) * COS_LUT[index] + x * COS_LUT[index + 1]);
                    }
                }
                else
                {
                    return COS_LUT[Round(x / Settings.SINCOS_LUT_PRECISION) % Settings.SINCOS_LUT_LENGTH];
                }
            }
            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 (float)Math.Cos(x);
            }
        }

Usage Example

Пример #1
0
        public static void CreateRotationalTransform(float angle, Mat22 result)
        {
            float c = MathUtils.Cos(angle);
            float s = MathUtils.Sin(angle);

            result.Ex.X = c;
            result.Ey.X = -s;
            result.Ex.Y = s;
            result.Ey.Y = c;
        }
All Usage Examples Of Box2D.Common.MathUtils::Cos