コード例 #1
0
        public void Addition()
        {
            Vector4F a = new Vector4F(1.0f, 2.0f, 3.0f, 4.0f);
            Vector4F b = new Vector4F(2.0f, 3.0f, 4.0f, 5.0f);
            Vector4F c = Vector4F.Add(a, b);

            Assert.AreEqual(new Vector4F(3.0f, 5.0f, 7.0f, 9.0f), c);
        }
コード例 #2
0
            public void adding_vectors_leaves_right_unchanged()
            {
                var left          = new Vector4F(1.0f, 2, 10, -4);
                var right         = new Vector4F(3.0f, 4, 11, 1);
                var expectedRight = new Vector4F(right);

                left.Add(right);

                Assert.Equal(expectedRight, right);
            }
コード例 #3
0
            public void adding_vector_adds_to_components()
            {
                var actual   = new Vector4F(1.0f, 2, 10, -4);
                var right    = new Vector4F(3.0f, 4, 11, 1);
                var expected = new Vector4F(4.0f, 6, 21, -3);

                actual.Add(right);

                Assert.Equal(expected, actual);
            }
コード例 #4
0
        public void Add()
        {
            Vector4F v1 = new Vector4F(1.0f, 2.0f, 3.0f, 4.0f);
            Vector4F v2 = new Vector4F(4.0f, 5.0f, 6.0f, 7.0f);

            Vector4F v3 = v1 + v2;
            Assert.AreEqual(5.0f, v3.X, 1e-14);
            Assert.AreEqual(7.0f, v3.Y, 1e-14);
            Assert.AreEqual(9.0f, v3.Z, 1e-14);
            Assert.AreEqual(11.0f, v3.W, 1e-14);

            Vector4F v4 = v1.Add(v2);
            Assert.AreEqual(5.0f, v4.X, 1e-14);
            Assert.AreEqual(7.0f, v4.Y, 1e-14);
            Assert.AreEqual(9.0f, v4.Z, 1e-14);
            Assert.AreEqual(11.0f, v4.W, 1e-14);
        }