Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
        public void TestEquality()
        {
            var rot1 = new GridRotation(1, true);
            var rot2 = new GridRotation(1, true);
            var rot3 = new GridRotation(1);

            Assert.Equal(rot1, rot2);
            Assert.True(rot1 == rot2);
            Assert.NotEqual(rot1, rot3);
            Assert.True(rot1 != rot3);
        }
Ejemplo n.º 3
0
    public void SetRotation(GridRotation r)
    {
        switch (r)
        {
        case GridRotation.Down:
            transform.rotation = new Quaternion(0, 1, 0, 0);
            break;

        case GridRotation.Up:
            transform.rotation = new Quaternion(0, 0, 0, 1);
            break;

        case GridRotation.Left:
            transform.rotation = new Quaternion(0, -1, 0, 1);
            break;

        case GridRotation.Right:
            transform.rotation = new Quaternion(0, 1, 0, 1);
            break;
        }
        Rotation = r;
    }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
 public static Direction RotateWithEightDirections(Direction direction, GridRotation rotation)
 {
     return((Direction)(((int)direction + (int)rotation) % 8));
 }
Ejemplo n.º 6
0
 public static Direction Rotate(Direction direction, GridRotation rotation)
 {
     return((Direction)(((int)direction + (int)rotation) % 4));
 }
Ejemplo n.º 7
0
        public void TestToRadians(int ticks, int subdivision, double expected)
        {
            var rot = new GridRotation(ticks);

            Assert.Equal(expected, rot.ToRadians(subdivision));
        }
Ejemplo n.º 8
0
 public void Rotate(GridRotation rotation)
 {
     throw new NotImplementedException();
 }