示例#1
0
        public void GetHashCodeTest()
        {
            PoseD p1 = new PoseD(new Vector3D(1, 2, 3), QuaternionD.CreateRotationY(0.3));
            PoseD p2 = new PoseD(new Vector3D(1, 2, 3), QuaternionD.CreateRotationY(0.3));

            Assert.AreEqual(p1.GetHashCode(), p2.GetHashCode());

            p1 = new PoseD(new Vector3D(1, 2, 3), QuaternionD.CreateRotationY(0.3));
            p2 = new PoseD(new Vector3D(2, 1, 3), QuaternionD.CreateRotationY(0.3));
            Assert.AreNotEqual(p1.GetHashCode(), p2.GetHashCode());

            // Too bad two rotation matrices that differ only by the sign of the angle
            // (+/- angle with same axis) have the same hashcodes. See KB -> .NET --> GetHashCode
            //p1 = new PoseD(new Vector3D(1, 2, 3), QuaternionD.CreateRotationY(0.3));
            //p2 = new PoseD(new Vector3D(1, 2, 3), QuaternionD.CreateRotationY(-0.3));
            //Assert.AreNotEqual(p1.GetHashCode(), p2.GetHashCode());
        }
示例#2
0
        public void GetHashCodeTest()
        {
            PoseD p1 = new PoseD(new Vector3D(1, 2, 3), QuaternionD.CreateRotationY(0.3));
              PoseD p2 = new PoseD(new Vector3D(1, 2, 3), QuaternionD.CreateRotationY(0.3));

              Assert.AreEqual(p1.GetHashCode(), p2.GetHashCode());

              p1 = new PoseD(new Vector3D(1, 2, 3), QuaternionD.CreateRotationY(0.3));
              p2 = new PoseD(new Vector3D(2, 1, 3), QuaternionD.CreateRotationY(0.3));
              Assert.AreNotEqual(p1.GetHashCode(), p2.GetHashCode());

              // Too bad two rotation matrices that differ only by the sign of the angle
              // (+/- angle with same axis) have the same hashcodes. See KB -> .NET --> GetHashCode
              //p1 = new PoseD(new Vector3D(1, 2, 3), QuaternionD.CreateRotationY(0.3));
              //p2 = new PoseD(new Vector3D(1, 2, 3), QuaternionD.CreateRotationY(-0.3));
              //Assert.AreNotEqual(p1.GetHashCode(), p2.GetHashCode());
        }