コード例 #1
0
        internal static double AbnCalculator(EdgeWithScores eachEdge)
        {
            double ABN;

            if (eachEdge.Edge.InternalAngle <= Math.PI)
            {
                ABN = (Math.PI - eachEdge.Edge.InternalAngle) * 180 / Math.PI;
            }
            else
            {
                ABN = eachEdge.Edge.InternalAngle * 180 / Math.PI;
            }

            if (ABN >= 180)
            {
                ABN -= 180;
            }

            if (ABN > 179.5)
            {
                ABN = 180 - ABN;
            }

            if (Double.IsNaN(ABN))
            {
                var eee = eachEdge.Edge.OwnedFace.Normal.dotProduct(eachEdge.Edge.OtherFace.Normal);
                if (eee > 1)
                {
                    eee = 1;
                }
                ABN = Math.Acos(eee);
            }
            return(ABN);
        }
コード例 #2
0
        private static void EdgeFuzzyClassification(EdgeWithScores e)
        {
            var ABN   = AbnCalculator(e);
            var MCM   = McmCalculator(e);
            var SM    = SmCalculator(e);
            var ABNid = CatAndProbFinder(ABN, listOfLimitsABN);
            var MCMid = CatAndProbFinder(MCM, listOfLimitsMCM);
            var SMid  = CatAndProbFinder(SM, listOfLimitsSM);

            if (ABNid.Count == 2 && ABNid[0].SequenceEqual(ABNid[1]))
            {
                ABNid.RemoveAt(0);
            }
            e.CatProb = new Dictionary <int, double>();
            foreach (var ABNprobs in ABNid)
            {
                foreach (var MCMProbs in MCMid)
                {
                    foreach (var SMProbs in SMid)
                    {
                        double Prob;
                        int    group = EdgeClassifier2(ABNprobs, MCMProbs, SMProbs, edgeRules, out Prob);
                        if (!e.CatProb.Keys.Contains(@group))
                        {
                            e.CatProb.Add(@group, Prob);
                        }
                        else if (e.CatProb[@group] < Prob)
                        {
                            e.CatProb[@group] = Prob;
                        }
                    }
                }
            }
        }
コード例 #3
0
        internal static double McmCalculator(EdgeWithScores eachEdge)
        {
            var cenMass1  = eachEdge.Edge.OwnedFace.Center;
            var cenMass2  = eachEdge.Edge.OtherFace.Center;
            var vector1   = new[] { cenMass1[0] - eachEdge.Edge.From.Position[0], cenMass1[1] - eachEdge.Edge.From.Position[1], cenMass1[2] - eachEdge.Edge.From.Position[2] };
            var vector2   = new[] { cenMass2[0] - eachEdge.Edge.From.Position[0], cenMass2[1] - eachEdge.Edge.From.Position[1], cenMass2[2] - eachEdge.Edge.From.Position[2] };
            var distance1 = eachEdge.Edge.Vector.normalize().dotProduct(vector1);
            var distance2 = eachEdge.Edge.Vector.normalize().dotProduct(vector2);
            //Mapped Center of Mass
            var MCM = (Math.Abs(distance1 - distance2)) / eachEdge.Edge.Length;

            return(MCM);
        }
コード例 #4
0
        internal static double SmCalculator(EdgeWithScores eachEdge)
        {
            //var edgesOfFace1 = new List<Edge>(eachEdge.Edge.OwnedFace.Edges);
            var edgesOfFace1Length = eachEdge.Edge.OwnedFace.Edges.Select(e => e.Length).ToList();

            if (edgesOfFace1Length.Count < 3)
            {
                // find the missing edge and add its length
                edgesOfFace1Length.Add(AddMissingEdgeLength(eachEdge.Edge.OwnedFace.Edges));
            }
            edgesOfFace1Length.Sort();
            //var edgesOfFace2 = new List<Edge>(eachEdge.Edge.OtherFace.Edges);
            var edgesOfFace2Length = eachEdge.Edge.OtherFace.Edges.Select(e => e.Length).ToList();

            if (edgesOfFace2Length.Count < 3)
            {
                // find the missing edge and add its length
                edgesOfFace2Length.Add(AddMissingEdgeLength(eachEdge.Edge.OtherFace.Edges));
            }
            edgesOfFace2Length.Sort();
            //if (edgesOfFace1.Count < 3 || edgesOfFace2.Count < 3) return double.PositiveInfinity;
            //edgesOfFace1 = edgesOfFace1.OrderBy(a => a.Length).ToList();
            //edgesOfFace2 = edgesOfFace2.OrderBy(a => a.Length).ToList();

            double smallArea, largeArea;

            if (eachEdge.Edge.OwnedFace.Area >= eachEdge.Edge.OtherFace.Area)
            {
                largeArea = eachEdge.Edge.OwnedFace.Area;
                smallArea = eachEdge.Edge.OtherFace.Area;
            }
            else
            {
                largeArea = eachEdge.Edge.OtherFace.Area;
                smallArea = eachEdge.Edge.OwnedFace.Area;
            }

            var r11 = edgesOfFace1Length[0] / edgesOfFace1Length[1];
            var r12 = edgesOfFace1Length[0] / edgesOfFace1Length[2];
            var r13 = edgesOfFace1Length[1] / edgesOfFace1Length[2];
            var r21 = edgesOfFace2Length[0] / edgesOfFace2Length[1];
            var r22 = edgesOfFace2Length[0] / edgesOfFace2Length[2];
            var r23 = edgesOfFace2Length[1] / edgesOfFace2Length[2];

            var similarity     = Math.Abs(r11 - r21) + Math.Abs(r12 - r22) + Math.Abs(r13 - r23); // cannot exceed 3
            var areaSimilarity = 3 * Math.Abs(1 - (smallArea / largeArea));

            var SM = similarity + areaSimilarity;

            return(SM);
        }