Platformer.PrimitiveLine.CreateCircle C# (CSharp) Метод

CreateCircle() публичный Метод

Creates a circle starting from 0, 0.
public CreateCircle ( float radius, int sides ) : void
radius float The radius (half the width) of the circle.
sides int The number of sides on the circle (the more the detailed).
Результат void
        public void CreateCircle(float radius, int sides)
        {
            vectors.Clear();

            float max = 2 * (float)Math.PI;
            float step = max / (float)sides;

            for (float theta = 0; theta < max; theta += step)
            {
                vectors.Add(new Vector2(radius * (float)Math.Cos((double)theta),
                    radius * (float)Math.Sin((double)theta)));
            }

            // then add the first vector again so it's a complete loop
            vectors.Add(new Vector2(radius * (float)Math.Cos(0),
                    radius * (float)Math.Sin(0)));
        }