예제 #1
0
        [Test] public void Orthonormalise()
        {
            var a2b = new m4x4();

            a2b.x = new v4(-2.0f, 3.0f, 1.0f, 0.0f);
            a2b.y = new v4(4.0f, -1.0f, 2.0f, 0.0f);
            a2b.z = new v4(1.0f, -2.0f, 4.0f, 0.0f);
            a2b.w = new v4(1.0f, 2.0f, 3.0f, 1.0f);
            Assert.True(Math_.IsOrthonormal(Math_.Orthonormalise(a2b)));
        }
예제 #2
0
 public void TestOriFromDir()
 {
     var dir = new v4(0, 1, 0, 0);
     {
         var ori = Math_.OriFromDir(EAxisId.PosZ, dir, v4.ZAxis);
         Assert.True(dir == ori.z);
         Assert.True(Math_.IsOrthonormal(ori));
     }
     {
         var ori = Math_.OriFromDir(EAxisId.NegX, dir);
         Assert.True(dir == -ori.x);
         Assert.True(Math_.IsOrthonormal(ori));
     }
 }
예제 #3
0
        [Test] public void CreateFrom()
        {
            var rnd = new Random(123456789);
            var V1  = v4.Random3(0.0f, 10.0f, 1.0f, rnd);
            var a2b = m4x4.Transform(v4.Random3N(0.0f, rnd), rnd.FloatC(0, (float)Math_.TauBy2), v4.Random3(0.0f, 10.0f, 1.0f, rnd));
            var b2c = m4x4.Transform(v4.Random3N(0.0f, rnd), rnd.FloatC(0, (float)Math_.TauBy2), v4.Random3(0.0f, 10.0f, 1.0f, rnd));

            Assert.True(Math_.IsOrthonormal(a2b));
            Assert.True(Math_.IsOrthonormal(b2c));

            var V2  = a2b * V1;
            var V3  = b2c * V2;
            var a2c = b2c * a2b;
            var V4  = a2c * V1;

            Assert.True(Math_.FEql(V3, V4));
        }
예제 #4
0
        [Test] public void CreateFrom2()
        {
            var m1 = m4x4.Transform(1.0f, 0.5f, 0.7f, v4.Origin);
            var m2 = new m4x4(new quat(1.0f, 0.5f, 0.7f), v4.Origin);

            Assert.True(Math_.IsOrthonormal(m1));
            Assert.True(Math_.IsOrthonormal(m2));
            Assert.True(Math_.FEql(m1, m2));

            var rng  = new Random(123456879);
            var ang  = rng.FloatC(0.0f, 1.0f);
            var axis = v4.Random3N(0.0f, rng);

            m1 = m4x4.Transform(axis, ang, v4.Origin);
            m2 = new m4x4(new quat(axis, ang), v4.Origin);
            Assert.True(Math_.IsOrthonormal(m1));
            Assert.True(Math_.IsOrthonormal(m2));
            Assert.True(Math_.FEql(m1, m2));
        }