Engines/FlatRedBallXNA/FlatRedBall/Math/Geometry/Polygon.cs
/// <summary>
/// Returns an equilateral shape of numberOfSides sides.
/// </summary>
/// <remarks>
/// The newly-created Polygon is invisible and is not part of the ShapeManager.
/// </remarks>
/// <param name="numberOfSides">The number of sides of the Polygon.  Must be at least 3.</param>
/// <param name="angleOfFirstPoint">The angle relative to the polygon of the first point.</param>
/// <returns>The newly-created Polygon.</returns>
Returns an equilateral shape of numberOfSides sides.
Returns an equilateral shape of numberOfSides sides .
static public Polygon CreateEquilateral(int numberOfSides, float radius, float angleOfFirstPoint)
        {
            Polygon polygon = new Polygon();
            int numberOfSidesPlusOne = numberOfSides + 1;
            Point[] points = new Point[numberOfSidesPlusOne];
            float angleOfCurrentPoint;
            for (int i = 0; i < numberOfSides + 1; i++)
            {
                angleOfCurrentPoint = angleOfFirstPoint + (float)( -i * System.Math.PI * 2) / (float)(numberOfSides);
                points[i].X = (float)(System.Math.Cos(angleOfCurrentPoint) * radius);
                points[i].Y = (float)(System.Math.Sin(angleOfCurrentPoint) * radius);
            }
            polygon.Points = points;
            return polygon;
        }
static public Polygon CreateEquilateral ( int numberOfSides , float radius , float angleOfFirstPoint ) { Polygon polygon = new Polygon ( ) ; int numberOfSidesPlusOne = numberOfSides + 1 ; Point [ ] points = new Point [ numberOfSidesPlusOne ] ; float angleOfCurrentPoint ; for ( int i = 0 ; i < numberOfSides + 1 ; i ++ ) { angleOfCurrentPoint = angleOfFirstPoint + ( float ) ( - i * System . Math . PI * 2 ) / ( float ) ( numberOfSides ) ; points [ i ] . X = ( float ) ( System . Math . Cos ( angleOfCurrentPoint ) * radius ) ; points [ i ] . Y = ( float ) ( System . Math . Sin ( angleOfCurrentPoint ) * radius ) ; } polygon . Points = points ; return polygon ; }
Returns an equilateral shape of numberOfSides sides.
Returns an equilateral shape of numberOfSides sides .
The newly-created Polygon.
The newly - created Polygon .
numberOfSides
int
The number of sides of the Polygon.  Must be at least 3.
The number of sides of the Polygon . Must be at least 3 .
radius
float
angleOfFirstPoint
float
The angle relative to the polygon of the first point.
The angle relative to the polygon of the first point .
remarks
The newly-created Polygon is invisible and is not part of the ShapeManager.
The newly - created Polygon is invisible and is not part of the ShapeManager .