Пример #1
0
        public void CrossProduct()
        {
            {
                var v0 = new v8 <Motion>(1, 1, 1, 2, 2, 2);
                var v1 = new v8 <Motion>(-1, -2, -3, -4, -5, -6);
                var r0 = Math_.Cross(v0, v1);
                var r1 = Math_.CPM(v0) * v1;
                Assert.True(Math_.FEql(r0, r1));
            }
            {
                var v0 = new v8 <Force>(1, 1, 1, 2, 2, 2);
                var v1 = new v8 <Force>(-1, -2, -3, -4, -5, -6);
                var r0 = Math_.Cross(v0, v1);
                var r1 = Math_.CPM(v0) * v1;
                Assert.True(Math_.FEql(r0, r1));
            }
            {            // Test: vx* == -Transpose(vx)
                var rng = new Random(321);
                var v   = v8 <IVectorSpace> .Random(-5f, +5f, rng);

                var m0 = Math_.CPM(v.Cast <Motion>());                // vx
                var m1 = Math_.CPM(v.Cast <Force>());                 // vx*
                var m2 = Math_.Transpose(m1);
                var m3 = (-m2).Cast <Motion, Motion>();
                Assert.True(Math_.FEql(m0, m3));
            }
        }
Пример #2
0
        public void DotProduct()
        {
            var a    = new v8 <Motion>(+1, +2, +3, +4, +5, +6);
            var b    = new v8 <Force>(-1, -2, -3, -4, -5, -6);
            var pwr0 = Math_.Dot(a, b);
            var pwr1 = Math_.Dot(b, a);

            Assert.True(Math_.FEql(pwr0, -91));
            Assert.True(Math_.FEql(pwr1, -91));
        }