Пример #1
0
        public void ToOtherTransform()
        {
            Point point = Auxilaries.RandomPoint();

            Point expected = point;
            Point actual   = point.ChangeTransform(null, null);

            Assert.AreEqual(expected, actual);
            Assert.AreNotSame(expected, actual);
        }
        private void TestGetPoint_InvalidEnum_Helper()
        {
            Point staticPoint = Auxilaries.RandomPoint();
            Point modelPoint  = Auxilaries.RandomPoint();

            Correspondence correspondence = new Correspondence(
                staticPoint: staticPoint,
                modelPoint: modelPoint
                );

            Fragment.ICPFragmentType type = (Fragment.ICPFragmentType) 99;

            correspondence.GetPoint(type);
        }
        public void TestGetPoint_StaticPoint()
        {
            Point staticPoint = Auxilaries.RandomPoint();
            Point modelPoint  = Auxilaries.RandomPoint();

            Correspondence correspondence = new Correspondence(
                staticPoint: staticPoint,
                modelPoint: modelPoint
                );

            Fragment.ICPFragmentType type = Fragment.ICPFragmentType.Static;

            Point actual = correspondence.GetPoint(type);

            Assert.AreEqual(staticPoint, actual);
        }
        public void Test_Equals_AreNotEqual()
        {
            CorrespondenceCollection actual = correspondences;

            Point modelPoint  = Auxilaries.RandomPoint();
            Point staticPoint = Auxilaries.RandomPoint();

            modelPointList.Add(modelPoint);
            staticPointList.Add(staticPoint);
            correspondences.Add(new Correspondence(modelPoint: modelPoint, staticPoint: staticPoint));
            CorrespondenceCollection other = new CorrespondenceCollection(modelPointList, staticPointList, correspondenceList);

            Assert.IsFalse(actual.Equals(other));
            Assert.IsFalse(other.Equals(actual));
            Assert.AreNotEqual(actual.GetHashCode(), other.GetHashCode());
        }
        public void Init()
        {
            modelPointList     = new List <Point>();
            staticPointList    = new List <Point>();
            correspondenceList = new List <Correspondence>
            {
                Auxilaries.RandomCorrespondence(),
                    Auxilaries.RandomCorrespondence(),
                    Auxilaries.RandomCorrespondence(),
                    Auxilaries.RandomCorrespondence()
            };

            correspondences = new CorrespondenceCollection();
            foreach (Correspondence correspondence in correspondenceList)
            {
                correspondences.Add(correspondence);

                modelPointList.Add(correspondence.ModelPoint);
                staticPointList.Add(correspondence.StaticPoint);
            }
        }
        public void Test_Add_Correspondence()
        {
            Correspondence correspondence = Auxilaries.RandomCorrespondence();

            CorrespondenceCollection actual = new CorrespondenceCollection();

            actual.Add(correspondence);

            List <Correspondence> expected_correspondences = new List <Correspondence> {
                correspondence
            };
            List <Point> expected_modelpoints = new List <Point> {
                correspondence.ModelPoint
            };
            List <Point> expected_staticpoints = new List <Point> {
                correspondence.StaticPoint
            };

            Assert.That(actual.Correspondences, Is.EquivalentTo(expected_correspondences));
            Assert.That(actual.ModelPoints, Is.EquivalentTo(expected_modelpoints));
            Assert.That(actual.StaticPoints, Is.EquivalentTo(expected_staticpoints));
        }
Пример #7
0
        public void TestApplyTransform_NonNeutralTransform()
        {
            Vector3 normal = Auxilaries.RandomNormal();

            Point     point          = new Point(new Vector3(2.0f, 3.0f, 4.0f), normal);
            Matrix4x4 transformation = new Matrix4x4();

            transformation.SetTRS(
                pos: new Vector3(0.5f, 2, 4),
                q: Quaternion.identity,
                s: new Vector3(2, 0.5f, 2)
                );

            // The object is frist scaled, then rotated, then translated
            Point expected = new Point(new Vector3(4.5f, 3.5f, 12.0f), normal);
            Point actual   = point.ApplyTransform(transformation);

            Assert.That(actual.Position, Is.EqualTo(expected.Position));
            Assert.That(actual.Normal, Is.EqualTo(expected.Normal));
            Assert.That(actual.Color, Is.EqualTo(point.Color));

            Assert.That(actual, Is.Not.SameAs(point));
        }
Пример #8
0
        public void TestApplyTransform_NeutralTransform()
        {
            Vector3 normal   = Auxilaries.RandomNormal();
            Vector3 position = new Vector3(2.0f, 3.0f, 4.0f);

            Point     point          = new Point(position, normal);
            Matrix4x4 transformation = new Matrix4x4();

            transformation.SetTRS(
                pos: new Vector3(0, 0, 0),
                q: Quaternion.identity,
                s: new Vector3(1, 1, 1)
                );

            Point expected = new Point(position, normal);
            Point actual   = point.ApplyTransform(transformation);

            Assert.That(actual.Position, Is.EqualTo(expected.Position));
            Assert.That(actual.Normal, Is.EqualTo(expected.Normal));
            Assert.That(actual.Color, Is.EqualTo(point.Color));

            Assert.That(actual, Is.Not.SameAs(point));
        }
        public void Test_Add_DistanceNode()
        {
            Point staticPoint = Auxilaries.RandomPoint();
            Point modelPoint  = Auxilaries.RandomPoint();
            float distance    = 3;

            DistanceNode node = new DistanceNode(
                modelPoint: modelPoint,
                staticPoint: staticPoint,
                distance: distance
                );

            CorrespondenceCollection actual = correspondences;

            correspondences.Add(node);

            modelPointList.Add(modelPoint);
            staticPointList.Add(staticPoint);
            correspondenceList.Add(new Correspondence(staticPoint: staticPoint, modelPoint: modelPoint));
            CorrespondenceCollection expected = new CorrespondenceCollection(modelPointList, staticPointList, correspondenceList);

            Assert.AreEqual(expected, actual);
        }