Exemplo n.º 1
0
 public void TestSin()
 {
     for (Double deg = -360.0; deg <= 360.0; deg += 0.1)
     {
         Double  rad      = deg * DoublePrecision.Maths.Deg2Rad;
         Fixed64 f        = rad;
         Fixed64 fs       = Fixed64.Sin(f);
         Double  result   = fs.ToDouble();
         Double  expected = Math.Sin(rad);
         Assert.That(result,
                     Is.EqualTo(expected).Within(MathsTests.TestTolerance).                           // Check that result is within test tolerance for Fixed64
                     Or.EqualTo(expected).Within(MathsTests.PercentageTolerance * Math.Abs(result))); // or that result is within test percentage for Fixed64.
     }
 }
Exemplo n.º 2
0
        public static void CreateRotationZ(Fixed64 radians, out Fixed64Matrix result)
        {
            Fixed64 num2 = Fixed64.Cos(radians);
            Fixed64 num  = Fixed64.Sin(radians);

            result.M11 = num2;
            result.M12 = num;
            result.M13 = Fixed64.Zero;
            result.M21 = -num;
            result.M22 = num2;
            result.M23 = Fixed64.Zero;
            result.M31 = Fixed64.Zero;
            result.M32 = Fixed64.Zero;
            result.M33 = Fixed64.One;
        }
Exemplo n.º 3
0
        public static Fixed64Matrix CreateRotationZ(Fixed64 radians)
        {
            Fixed64Matrix matrix;
            Fixed64       num2 = Fixed64.Cos(radians);
            Fixed64       num  = Fixed64.Sin(radians);

            matrix.M11 = num2;
            matrix.M12 = num;
            matrix.M13 = Fixed64.Zero;
            matrix.M21 = -num;
            matrix.M22 = num2;
            matrix.M23 = Fixed64.Zero;
            matrix.M31 = Fixed64.Zero;
            matrix.M32 = Fixed64.Zero;
            matrix.M33 = Fixed64.One;
            return(matrix);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a matrix which rotates around the given axis by the given angle.
        /// </summary>
        /// <param name="axis">The axis.</param>
        /// <param name="angle">The angle.</param>
        /// <param name="result">The resulting rotation matrix</param>
        public static void CreateFromAxisAngle(ref Fixed64Vector3 axis, Fixed64 angle, out Fixed64Matrix result)
        {
            Fixed64 x     = axis.x;
            Fixed64 y     = axis.y;
            Fixed64 z     = axis.z;
            Fixed64 num2  = Fixed64.Sin(angle);
            Fixed64 num   = Fixed64.Cos(angle);
            Fixed64 num11 = x * x;
            Fixed64 num10 = y * y;
            Fixed64 num9  = z * z;
            Fixed64 num8  = x * y;
            Fixed64 num7  = x * z;
            Fixed64 num6  = y * z;

            result.M11 = num11 + (num * (Fixed64.One - num11));
            result.M12 = (num8 - (num * num8)) + (num2 * z);
            result.M13 = (num7 - (num * num7)) - (num2 * y);
            result.M21 = (num8 - (num * num8)) - (num2 * z);
            result.M22 = num10 + (num * (Fixed64.One - num10));
            result.M23 = (num6 - (num * num6)) + (num2 * x);
            result.M31 = (num7 - (num * num7)) + (num2 * y);
            result.M32 = (num6 - (num * num6)) - (num2 * x);
            result.M33 = num9 + (num * (Fixed64.One - num9));
        }
Exemplo n.º 5
0
 public static F64Vec4 Sin(F64Vec4 a)
 {
     return(new F64Vec4(Fixed64.Sin(a.RawX), Fixed64.Sin(a.RawY), Fixed64.Sin(a.RawZ), Fixed64.Sin(a.RawW)));
 }
Exemplo n.º 6
0
 public static F64Vec3 Sin(F64Vec3 a)
 {
     return(new F64Vec3(Fixed64.Sin(a.RawX), Fixed64.Sin(a.RawY), Fixed64.Sin(a.RawZ)));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Returns the sine of value.
 /// </summary>
 public static Fixed64 Sin(Fixed64 value)
 {
     return(Fixed64.Sin(value));
 }
Exemplo n.º 8
0
 public static F64 Sin(F64 a)
 {
     return(FromRaw(Fixed64.Sin(a.Raw)));
 }
Exemplo n.º 9
0
 public static F64Vec2 Sin(F64Vec2 a)
 {
     return(new F64Vec2(Fixed64.Sin(a.RawX), Fixed64.Sin(a.RawY)));
 }