Beispiel #1
0
 public static bool FEqlRelative(Rect lhs, Rect rhs, double tol)
 {
     return
         (Math_.FEqlRelative(lhs.X, rhs.X, tol) &&
          Math_.FEqlRelative(lhs.Y, rhs.Y, tol) &&
          Math_.FEqlRelative(lhs.Width, rhs.Width, tol) &&
          Math_.FEqlRelative(lhs.Height, rhs.Height, tol));
 }
Beispiel #2
0
        public void TestInversion()
        {
            var rng = new Random();
            {
                var m      = m3x4.Random(v4.Random3N(0, rng), -Math_.TauF, +Math_.TauF, rng);
                var inv_m0 = Math_.InvertFast(m);
                var inv_m1 = Math_.Invert(m);
                Assert.True(Math_.FEqlRelative(inv_m0, inv_m1, 0.001f));
            } {
                for (; ;)
                {
                    var m = m3x4.Random(-5.0f, +5.0f, 0, rng);
                    if (!Math_.IsInvertible(m))
                    {
                        continue;
                    }
                    var inv_m = Math_.Invert(m);
                    var I0    = inv_m * m;
                    var I1    = m * inv_m;

                    Assert.True(Math_.FEqlRelative(I0, m3x4.Identity, 0.001f));
                    Assert.True(Math_.FEqlRelative(I1, m3x4.Identity, 0.001f));
                    break;
                }
            } {
                var m = new m3x4(
                    new v4(0.25f, 0.5f, 1.0f, 0.0f),
                    new v4(0.49f, 0.7f, 1.0f, 0.0f),
                    new v4(1.0f, 1.0f, 1.0f, 0.0f));
                var INV_M = new m3x4(
                    new v4(10.0f, -16.666667f, 6.66667f, 0.0f),
                    new v4(-17.0f, 25.0f, -8.0f, 0.0f),
                    new v4(7.0f, -8.333333f, 2.333333f, 0.0f));

                var inv_m = Math_.Invert(m);
                Assert.True(Math_.FEqlRelative(inv_m, INV_M, 0.001f));
            }
        }
Beispiel #3
0
 public static bool FEqlRelative(Vector lhs, Vector rhs, double tol)
 {
     return
         (Math_.FEqlRelative(lhs.X, rhs.X, tol) &&
          Math_.FEqlRelative(lhs.Y, rhs.Y, tol));
 }
Beispiel #4
0
 public static bool FEqlRelative(Point lhs, Point rhs, double tol)
 {
     return
         (Math_.FEqlRelative(lhs.X, rhs.X, tol) &&
          Math_.FEqlRelative(lhs.Y, rhs.Y, tol));
 }
Beispiel #5
0
 public static bool FEqlRelative(Size lhs, Size rhs, double tol)
 {
     return
         (Math_.FEqlRelative(lhs.Width, rhs.Width, tol) &&
          Math_.FEqlRelative(lhs.Height, rhs.Height, tol));
 }