Exemple #1
0
        public void CountMeanOfNode_CountCorrectMean()
        {
            Params.inputDataDimension = 3;
            Node node = new Node(1, 1, 0.0, 0.0, "");
            // cluster 1
            ClusterX newClusterX1 = new ClusterX(node);

            newClusterX1.Items.Add(new Vector(new double[] { 1, 2, 3 }, new double[] { 1, -2, 3 }));
            newClusterX1.Items.Add(new Vector(new double[] { 2, 3, 4 }, new double[] { 2, 3, 4 }));
            newClusterX1.Items.Add(new Vector(new double[] { 3, 4, 5 }, new double[] { 3, 4, 5 }));
            newClusterX1.Mean = new Vector(new double[] { 1, 2, 3 });
            node.ClustersX.Add(newClusterX1);

            ClusterPair clusterPair1 = new ClusterPair();

            clusterPair1.X = newClusterX1;

            newClusterX1.SetClusterPair(clusterPair1);

            node.ClusterPairs.Add(clusterPair1);

            node.CountMeanAndVarianceMDF();
            node.CountOfSamples = 4;

            node.UpdateMeanAndVarianceMdf(new Vector(new double[] { 4, 5, 6 }, new double[] { 4, 5, 6 }));

            node.CountOfSamples = 5;

            node.UpdateMeanAndVarianceMdf(new Vector(new double[] { 5, 6, -7 }, new double[] { 5, 6, -7 }));
            Assert.AreEqual(node.VarianceMDF[0], 2.5);
            Assert.AreEqual(node.VarianceMDF[1], 9.7);
            Assert.AreEqual(node.VarianceMDF[2], 27.7);
        }
Exemple #2
0
        protected void CheckMeshLinkedToSkeleton(FbxMesh origMesh, FbxMesh importMesh)
        {
            FbxSkin origSkin = origMesh.GetDeformer(0, new FbxStatus()) as FbxSkin;

            Assert.IsNotNull(origSkin);

            FbxSkin importSkin = origMesh.GetDeformer(0, new FbxStatus()) as FbxSkin;

            Assert.IsNotNull(importSkin);

            ClusterPair[] clusters = new ClusterPair[3];

            for (int i = 0; i < 3; i++)
            {
                FbxCluster origCluster = origSkin.GetCluster(i);
                Assert.IsNotNull(origCluster);

                FbxCluster importCluster = importSkin.GetCluster(i);
                Assert.IsNotNull(importCluster);

                clusters [i] = new ClusterPair(origCluster, importCluster);
            }

            foreach (var c in clusters)
            {
                FbxAMatrix origTransformMatrix   = null;
                FbxAMatrix importTransformMatrix = null;
                Assert.AreEqual(c.orig.GetTransformMatrix(origTransformMatrix), c.import.GetTransformMatrix(importTransformMatrix));
                Assert.AreEqual(c.orig.GetTransformLinkMatrix(origTransformMatrix), c.import.GetTransformLinkMatrix(importTransformMatrix));

                Assert.AreEqual(c.orig.GetLink(), c.import.GetLink());
                Assert.AreEqual(c.orig.GetLinkMode(), c.import.GetLinkMode());
                Assert.AreEqual(c.orig.GetControlPointIndicesCount(), c.import.GetControlPointIndicesCount());

                for (int i = 0; i < c.orig.GetControlPointIndicesCount(); i++)
                {
                    Assert.AreEqual(c.orig.GetControlPointIndexAt(i), c.import.GetControlPointIndexAt(i));
                    Assert.AreEqual(c.orig.GetControlPointWeightAt(i), c.import.GetControlPointWeightAt(i));
                }
            }
        }
Exemple #3
0
        public void CountC_CountCCorrect()
        {
            Node node = new Node(0, 0, 0.0, 0.0, "");

            Params.inputDataDimension = 3;
            node.CountOfSamples       = 6;

            // cluster 1
            ClusterX newClusterX1 = new ClusterX(node);

            newClusterX1.Items.Add(new Vector(0, 0));
            newClusterX1.Items.Add(new Vector(0, 0));
            newClusterX1.Items.Add(new Vector(0, 0));
            newClusterX1.Mean = new Vector(new double[] { 1, 2, 3 });
            node.ClustersX.Add(newClusterX1);

            ClusterPair clusterPair1 = new ClusterPair();

            clusterPair1.X = newClusterX1;

            newClusterX1.SetClusterPair(clusterPair1);

            node.ClusterPairs.Add(clusterPair1);

            // cluster 2
            ClusterX newClusterX2 = new ClusterX(node);

            newClusterX2.Items.Add(new Vector(0, 0));
            newClusterX2.Items.Add(new Vector(0, 0));
            newClusterX2.Mean = new Vector(new double[] { 3, 3, 4 });
            node.ClustersX.Add(newClusterX2);

            ClusterPair clusterPair2 = new ClusterPair();

            clusterPair2.X = newClusterX2;

            newClusterX2.SetClusterPair(clusterPair2);

            node.ClusterPairs.Add(clusterPair2);

            // cluster 3
            ClusterX newClusterX3 = new ClusterX(node);

            newClusterX3.Items.Add(new Vector(0, 0));
            newClusterX3.Mean = new Vector(new double[] { 9, 6, 7 });
            node.ClustersX.Add(newClusterX3);

            ClusterPair clusterPair3 = new ClusterPair();

            clusterPair3.X = newClusterX3;

            newClusterX3.SetClusterPair(clusterPair3);

            node.ClusterPairs.Add(clusterPair3);

            Vector mean = node.GetCFromClustersX();

            Assert.AreEqual(mean.Values[0], 3);
            Assert.AreEqual(mean.Values[1], 3);
            Assert.AreEqual(mean.Values[2], 1);
        }
 protected override bool isFinished(ICollection<Cluster> currentClusters, ClusterPair lowestDistancePair)
 {
     return desiredClusterCount < 1 || desiredClusterCount >= currentClusters.Count;
 }
 protected override bool isFinished(ICollection<Cluster> currentClusters, ClusterPair lowestDistancePair)
 {
     return currentClusters.Count == minCountClustersToCreate || lowestDistancePair.Distance > maximumDistance;
 }