RenderingLibrary.Math.Geometry.LinePrimitive.CreateCircle C# (CSharp) Method

CreateCircle() public method

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).
return void
        public void CreateCircle(float radius, int sides)
        {
            mVectors.Clear();

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

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

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

Usage Example

Example #1
0
        private void UpdatePoints()
        {
            mLinePrimitive.CreateCircle(Radius, 15);

            if (mCircleOrigin == Geometry.CircleOrigin.TopLeft)
            {
                if (Rotation != 0)
                {
                    Matrix matrix = Matrix.CreateRotationZ(-MathHelper.ToRadians(Rotation));

                    var vector = Radius * matrix.Right + Radius * matrix.Up;

                    mLinePrimitive.Shift(vector.X, vector.Y);
                }
                else
                {
                    mLinePrimitive.Shift(Radius, Radius);
                }
            }
        }
All Usage Examples Of RenderingLibrary.Math.Geometry.LinePrimitive::CreateCircle