コード例 #1
0
        private float ComputeCoverage(TAMImageDiagram diagram, TAMMipmapLevel mipmapLevel)
        {
            var areaSum = 0.0;

            for (int i = 0; i < diagram.Strokes.Count; i++)
            {
                var currentStroke = diagram.Strokes[i];
                var baseArea      = Mathf.PI * Mathf.Pow(currentStroke.Length, 2) * 0.2; //todo

                for (int k = 0; k < i; k++)
                {
                    var otherStroke      = diagram.Strokes[k];
                    var intersectionArea =
                        MyMathUtils.IntersectionAreaOfTwoCircles(currentStroke.Length, currentStroke.Center, otherStroke.Length, otherStroke.Center);
                    baseArea -= intersectionArea;
                }

                areaSum += Math.Max(0.001f, baseArea); //todo what to do with other mipmapLevels
            }
            return((float)areaSum);
        }
コード例 #2
0
        private RankedPossibleStroke RankStroke(TAMStroke newStroke, TAMImageDiagram diagram)
        {
            // rank the bigger, the better
            var distanceSum      = 0f;
            var intersectionArea = 0f;

            foreach (var stroke in diagram.Strokes)
            {
                var intersection = MyMathUtils.IntersectionAreaOfTwoCircles(newStroke.Length, newStroke.Center, stroke.Length, stroke.Center);
                intersectionArea += intersection;
                distanceSum      += Vector2.Distance(newStroke.Center, stroke.Center);
            }

            var intersectionPercent = intersectionArea / (Math.PI * Math.Pow(newStroke.Length, 2));

            var rank = Mathf.Pow(distanceSum, (float)(2 - intersectionPercent));

            return(new RankedPossibleStroke()
            {
                Rank = rank,
                Stroke = newStroke
            });
        }