コード例 #1
0
        // seperates the internal points into a logical grid of cells
        internal void seperatePointsIntoGridCells(List <DelaunayTriangulator.Vertex> points, int angle)
        {
            GridRotation = Geometry.createGridTransformation(angle, BoundsWidth, BoundsHeight, NumFrames);

            SeperatedPoints = new Dictionary <SKPointI, HashSet <SKPoint> >();

            SKPointI gridIndex = new SKPointI();

            var newPoint = new SKPoint();

            foreach (var point in points)
            {
                newPoint.X = point.x;
                newPoint.Y = point.y;

                GridRotation.CellCoordsFromOriginPoint(ref gridIndex, newPoint);

                //if the SeperatedPoints distionary does not have a point already, initialize the list at that key
                if (!SeperatedPoints.ContainsKey(gridIndex))
                {
                    SeperatedPoints[gridIndex] = new HashSet <SKPoint>();
                }
                SeperatedPoints[gridIndex].Add(newPoint);
            }
        }
コード例 #2
0
        //saves
        internal HashSet <SKPoint> getTouchAreaRecPoints()
        {
            var touch = new HashSet <SKPoint>();

            var BL = new SKPoint(TouchLocation.X - TouchRadius, TouchLocation.Y - TouchRadius);
            var TR = new SKPoint(TouchLocation.X + TouchRadius, TouchLocation.Y + TouchRadius);

            var BLindex = new SKPointI();
            var TRindex = new SKPointI();

            GridRotation.CellCoordsFromOriginPoint(ref BLindex, BL);
            GridRotation.CellCoordsFromOriginPoint(ref TRindex, TR);

            var upperX = TRindex.X > BLindex.X ? TRindex.X : BLindex.X;
            var lowerX = TRindex.X < BLindex.X ? TRindex.X : BLindex.X;

            var upperY = TRindex.Y > BLindex.Y ? TRindex.Y : BLindex.Y;
            var lowerY = TRindex.Y < BLindex.Y ? TRindex.Y : BLindex.Y;

            var p = new SKPointI();

            for (var i = lowerX; i <= upperX; i++)
            {
                for (var j = lowerY; j <= upperY; j++)
                {
                    p.X = i;
                    p.Y = j;

                    if (SeperatedPoints.ContainsKey(p))
                    {
                        touch.UnionWith(SeperatedPoints[p]);
                    }
                }
            }

            return(touch);
        }