Advertisement
Guest User

Untitled

a guest
Feb 7th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1.     public class Boundaries
  2.     {
  3.         /// <summary>
  4.         /// Create a concave circle list of points.
  5.         /// </summary>
  6.         /// <param name="radius">Radius of the circle.</param>
  7.         /// <param name="numberOfEdges">Number of semi-circular edges (circle smoothness)</param>
  8.         /// <returns>In order collection of polygon vertices.</returns>
  9.         public static Vertices CreateConcaveSemiCircle(float radius, int numberOfEdges)
  10.         {
  11.             float stepSize = (float)Math.PI / (float)numberOfEdges;
  12.  
  13.             Vertices points = new Vertices();
  14.             points.Add(new Vector2(radius, 0)); // Origin Point, on Right Side
  15.  
  16.             for (int i = 1; i < numberOfEdges + 1; i++)
  17.             {
  18.                 //Moves Counter-Clockwise from Right Side
  19.                 points.Add(new Vector2((float)(radius * Math.Cos(stepSize * i)), (float)(-radius * Math.Sin(stepSize * i))));
  20.             }
  21.  
  22.             points.Add(new Vector2(-radius, 0)); // Left-Most Side
  23.  
  24.             for (int i = 1; i < numberOfEdges + 1; i++)
  25.             {
  26.                 //Moves Counter-Clockwise from Left Side
  27.                 points.Add(new Vector2((float)(-radius * Math.Cos(stepSize * i)), (float)(radius * Math.Sin(stepSize * i))));
  28.             }
  29.  
  30.             points.Add(new Vector2(radius, 0)); // Origin Point, links together shape.
  31.  
  32.             return points;
  33.         }
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement