예제 #1
0
파일: Math.cs 프로젝트: xdl810506/Dynamo
 /// <summary>
 ///     Finds the tangent of an angle.
 /// </summary>
 /// <param name="angle">Angle in degrees to take the tangent of.</param>
 /// <returns name="tan">Tangent of the angle.</returns>
 /// <search>tangent</search>
 public static double Tan(double angle)
 {
     if (!(Equals(CSMath.IEEERemainder(angle, 180), 0.0) || Equals(CSMath.IEEERemainder(angle, 180), 180.0))
         && (Equals(CSMath.IEEERemainder(angle, 90), 0.0) || Equals(CSMath.IEEERemainder(angle, 90), 90.0)))
         return Double.NaN;
     return CSMath.Tan(angle * kDegreesToRadians);
 }
예제 #2
0
파일: Math.cs 프로젝트: zjloscar/Dynamo
 public static double Tan(double value)
 {
     if (!(Double.Equals(CSMath.IEEERemainder(value, 180), 0.0) || Double.Equals(CSMath.IEEERemainder(value, 180), 180.0)) &&
         (Double.Equals(CSMath.IEEERemainder(value, 90), 0.0) || Double.Equals(CSMath.IEEERemainder(value, 90), 90.0)))
     {
         return(Double.NaN);
     }
     return(CSMath.Tan(value * kDegreesToRadians));
 }
예제 #3
0
        public static MatrixDouble CreateRotation(double radians, Point centerPoint)
        {
            MatrixDouble result;

            radians = (double)SM.IEEERemainder(radians, SM.PI * 2);

            double c, s;

            const double epsilon = 0.001f * (double)SM.PI / 180d; // 0.1% of a degree

            if ((radians > -epsilon) && (radians < epsilon))
            {
                // Exact case for zero rotation.
                c = 1;
                s = 0;
            }
            else if ((radians > SM.PI / 2 - epsilon) && (radians < SM.PI / 2 + epsilon))
            {
                // Exact case for 90 degree rotation.
                c = 0;
                s = 1;
            }
            else if ((radians < -SM.PI + epsilon) || (radians > SM.PI - epsilon))
            {
                // Exact case for 180 degree rotation.
                c = -1;
                s = 0;
            }
            else if ((radians > -SM.PI / 2 - epsilon) && (radians < -SM.PI / 2 + epsilon))
            {
                // Exact case for 270 degree rotation.
                c = 0;
                s = -1;
            }
            else
            {
                // Arbitrary rotation.
                c = (double)SM.Cos(radians);
                s = (double)SM.Sin(radians);
            }

            double x = centerPoint.X * (1 - c) + centerPoint.Y * s;
            double y = centerPoint.Y * (1 - c) - centerPoint.X * s;

            // [  c  s ]
            // [ -s  c ]
            // [  x  y ]
            result.M11 = c;
            result.M12 = s;
            result.M21 = -s;
            result.M22 = c;
            result.M31 = x;
            result.M32 = y;

            return(result);
        }
예제 #4
0
파일: Matrix3x2.cs 프로젝트: nicecai/Win2D
        public static Matrix3x2 CreateRotation(float radians, Vector2 centerPoint)
        {
            Matrix3x2 result;

            radians = (float)SM.IEEERemainder(radians, SM.PI * 2);

            float c, s;

            const float epsilon = 0.001f * (float)SM.PI / 180f;     // 0.1% of a degree

            if (radians > -epsilon && radians < epsilon)
            {
                // Exact case for zero rotation.
                c = 1;
                s = 0;
            }
            else if (radians > SM.PI / 2 - epsilon && radians < SM.PI / 2 + epsilon)
            {
                // Exact case for 90 degree rotation.
                c = 0;
                s = 1;
            }
            else if (radians < -SM.PI + epsilon || radians > SM.PI - epsilon)
            {
                // Exact case for 180 degree rotation.
                c = -1;
                s = 0;
            }
            else if (radians > -SM.PI / 2 - epsilon && radians < -SM.PI / 2 + epsilon)
            {
                // Exact case for 270 degree rotation.
                c = 0;
                s = -1;
            }
            else
            {
                // Arbitrary rotation.
                c = (float)SM.Cos(radians);
                s = (float)SM.Sin(radians);
            }

            float x = centerPoint.X * (1 - c) + centerPoint.Y * s;
            float y = centerPoint.Y * (1 - c) - centerPoint.X * s;

            // [  c  s ]
            // [ -s  c ]
            // [  x  y ]
            result.M11 = c; result.M12 = s;
            result.M21 = -s; result.M22 = c;
            result.M31 = x; result.M32 = y;

            return(result);
        }
예제 #5
0
 public static double IEEERemainder(this double x, double y)
 {
     return(Math.IEEERemainder(x, y));
 }
예제 #6
0
 public static Half IEEERemainder(Half x,
                                  Half y) =>
 (Half)M.IEEERemainder(x, y);
예제 #7
0
파일: Math.cs 프로젝트: zjloscar/Dynamo
 public static double IEEERemainder(double value1, double value2)
 {
     return(CSMath.IEEERemainder(value1, value2));
 }
예제 #8
0
 public static float IEEERemainder(float x, float y)
 {
     return((float)Math.IEEERemainder(x, y));
 }
예제 #9
0
 public static double IEEERemainder(double x, double y) => Math.IEEERemainder(x, y);
예제 #10
0
파일: Double.cs 프로젝트: zhk0603/runtime
 static double IFloatingPoint <double> .IEEERemainder(double left, double right)
 => Math.IEEERemainder(left, right);
예제 #11
0
 /// <inheritdoc cref="IFloatingPoint{TSelf}.IEEERemainder(TSelf, TSelf)" />
 public static double IEEERemainder(double left, double right) => Math.IEEERemainder(left, right);
예제 #12
0
 /// <summary>
 /// Reduces a given angle to a value between π and -π.
 /// </summary>
 /// <param name="angle">The angle.</param>
 public static float WrapAngle(float angle)
 {
     return((float)Math.IEEERemainder((double)angle, 6.2831854820251465));
 }
예제 #13
0
 public static nfloat IEEERemainder(nfloat x, nfloat y)
 {
     return((nfloat)Math.IEEERemainder((double)x, (double)y));
 }