FarseerPhysics.Common.PolygonTools.createEllipse C# (CSharp) Method

createEllipse() public static method

Creates a ellipse with the specified width, height and number of edges.
public static createEllipse ( float xRadius, float yRadius, int numberOfEdges ) : Vertices
xRadius float Width of the ellipse.
yRadius float Height of the ellipse.
numberOfEdges int The number of edges. The more edges, the more it resembles an ellipse
return Vertices
		public static Vertices createEllipse( float xRadius, float yRadius, int numberOfEdges )
		{
			var vertices = new Vertices();

			float stepSize = MathHelper.TwoPi / numberOfEdges;

			vertices.Add( new Vector2( xRadius, 0 ) );
			for( int i = numberOfEdges - 1; i > 0; --i )
				vertices.Add( new Vector2( xRadius * (float)Math.Cos( stepSize * i ),
										 -yRadius * (float)Math.Sin( stepSize * i ) ) );

			return vertices;
		}