示例#1
0
 /// <summary>
 /// Rotates the Polygon12 by a given angle in radians
 /// </summary>
 /// <param name="centerOfRotation"></param>
 /// <param name="angleInRadians"></param>
 public void rotatePolygon12(Vector2 centerOfRotation, float angleInRadians)
 {
     for (int i = 0; i < numOfPoints; i++)
     {
         point[i] = Util.rotatePoint(point[i], centerOfRotation, -angleInRadians);
     }
 }
示例#2
0
 /// <summary>
 /// Rotates the rect4 by a given angle in radians
 /// </summary>
 /// <param name="centerOfRotation"></param>
 /// <param name="angleInRadians"></param>
 public void rotateRect(Vector2 centerOfRotation, float angleInRadians)
 {
     point[0] = Util.rotatePoint(point[0], centerOfRotation, -angleInRadians);
     point[1] = Util.rotatePoint(point[1], centerOfRotation, -angleInRadians);
     point[2] = Util.rotatePoint(point[2], centerOfRotation, -angleInRadians);
     point[3] = Util.rotatePoint(point[3], centerOfRotation, -angleInRadians);
 }
示例#3
0
        /// <summary>
        /// Draw a line circle
        /// </summary>
        /// <param name="sb"></param>
        /// <param name="c"></param>
        /// <param name="center"></param>
        /// <param name="radius"></param>
        /// <param name="sides"></param>
        /// <param name="xScale"></param>
        static public void drawCircle(SpriteBatch sb, Color c, Vector2 center, float radius, int sides, float xScale)
        {
            Vector2 p    = new Vector2(center.X, center.Y + radius);
            Vector2 prev = new Vector2(0, 0);

            for (int i = 0; i <= sides; i++)
            {
                Vector2 pp = Util.rotatePoint(p, center, (float)(Math.PI * 2 / (sides - 1) * i));
                if (i != 0)
                {
                    drawLine(sb, c, pp, prev, 0);
                }
                prev = pp;
            }
        }
示例#4
0
        public Polygon12(Vector2 center, int sides, float radius, float initialAngleRadians)
        {
            Vector2 p    = new Vector2(center.X, center.Y + radius);
            Vector2 prev = new Vector2(0, 0);

            point       = new Vector2[maxNumOfPoints];
            numOfPoints = sides;

            for (int i = 0; i < sides; i++)
            {
                Vector2 pp = Util.rotatePoint(p, center, (float)(Math.PI * 2 / (sides) * i) + initialAngleRadians);
                point[i].X = pp.X;
                point[i].Y = pp.Y;
                prev       = pp;
            }
        }