コード例 #1
0
        public void ProjectTo2()
        {
            // Project (1, 1, 1) to axes
            Vector4F projection = new Vector4F(1, 1, 1, 0);

            projection.ProjectTo(Vector4F.UnitX);
            Assert.AreEqual(Vector4F.UnitX, projection);
            projection = Vector4F.One;
            projection.ProjectTo(Vector4F.UnitY);
            Assert.AreEqual(Vector4F.UnitY, projection);
            projection = Vector4F.One;
            projection.ProjectTo(Vector4F.UnitZ);
            Assert.AreEqual(Vector4F.UnitZ, projection);

            // Project axes to (1, 1, 1)
            Vector4F expected = new Vector4F(1, 1, 1, 0) / 3.0f;

            projection = Vector4F.UnitX;
            projection.ProjectTo(new Vector4F(1, 1, 1, 0));
            Assert.AreEqual(expected, projection);
            projection = Vector4F.UnitY;
            projection.ProjectTo(new Vector4F(1, 1, 1, 0));
            Assert.AreEqual(expected, projection);
            projection = Vector4F.UnitZ;
            projection.ProjectTo(new Vector4F(1, 1, 1, 0));
            Assert.AreEqual(expected, projection);
        }
コード例 #2
0
        public void ProjectTo()
        {
            // Project (1, 1, 1) to axes
            Vector4F v          = new Vector4F(1, 1, 1, 0);
            Vector4F projection = Vector4F.ProjectTo(v, Vector4F.UnitX);

            Assert.AreEqual(Vector4F.UnitX, projection);
            projection = Vector4F.ProjectTo(v, Vector4F.UnitY);
            Assert.AreEqual(Vector4F.UnitY, projection);
            projection = Vector4F.ProjectTo(v, Vector4F.UnitZ);
            Assert.AreEqual(Vector4F.UnitZ, projection);

            // Project axes to (1, 1, 1)
            Vector4F expected = new Vector4F(1, 1, 1, 0) / 3.0f;

            projection = Vector4F.ProjectTo(Vector4F.UnitX, v);
            Assert.AreEqual(expected, projection);
            projection = Vector4F.ProjectTo(Vector4F.UnitY, v);
            Assert.AreEqual(expected, projection);
            projection = Vector4F.ProjectTo(Vector4F.UnitZ, v);
            Assert.AreEqual(expected, projection);
        }
コード例 #3
0
ファイル: Vector4FTest.cs プロジェクト: Zolniu/DigitalRune
        public void ProjectTo2()
        {
            // Project (1, 1, 1) to axes
              Vector4F projection = new Vector4F(1, 1, 1, 0);
              projection.ProjectTo(Vector4F.UnitX);
              Assert.AreEqual(Vector4F.UnitX, projection);
              projection = Vector4F.One;
              projection.ProjectTo(Vector4F.UnitY);
              Assert.AreEqual(Vector4F.UnitY, projection);
              projection = Vector4F.One;
              projection.ProjectTo(Vector4F.UnitZ);
              Assert.AreEqual(Vector4F.UnitZ, projection);

              // Project axes to (1, 1, 1)
              Vector4F expected = new Vector4F(1, 1, 1, 0) / 3.0f;
              projection = Vector4F.UnitX;
              projection.ProjectTo(new Vector4F(1, 1, 1, 0));
              Assert.AreEqual(expected, projection);
              projection = Vector4F.UnitY;
              projection.ProjectTo(new Vector4F(1, 1, 1, 0));
              Assert.AreEqual(expected, projection);
              projection = Vector4F.UnitZ;
              projection.ProjectTo(new Vector4F(1, 1, 1, 0));
              Assert.AreEqual(expected, projection);
        }