fCraft.ShapesLib.MakeStarPoints C# (CSharp) Method

MakeStarPoints() private method

private MakeStarPoints ( double start_theta, int num_points, int Radius ) : System.Drawing.PointF[]
start_theta double
num_points int
Radius int
return System.Drawing.PointF[]
        private PointF[] MakeStarPoints( double start_theta, int num_points, int Radius )
        {
            double theta, dtheta;
            PointF[] result;
            float cx = Radius;
            float cy = Radius;
            int skip = ( int )( ( num_points - 1 ) / 2.0 );

            // If this is a polygon, don't bother with concave points.
            if ( skip == 1 ) {
                result = new PointF[num_points];
                theta = start_theta;
                dtheta = 2 * Math.PI / num_points;
                for ( int i = 0; i < num_points; i++ ) {
                    result[i] = new PointF(
                        ( float )( cx + cx * Math.Cos( theta ) ),
                        ( float )( cy + cy * Math.Sin( theta ) ) );
                    theta += dtheta;
                }
                return result;
            }

            // Find the radius for the concave vertices.
            double concave_radius = CalculateConcaveRadius( num_points, skip );

            // Make the points.
            result = new PointF[2 * num_points];
            theta = start_theta;
            dtheta = Math.PI / num_points;
            for ( int i = 0; i < num_points; i++ ) {
                result[2 * i] = new PointF(
                    ( float )( cx + cx * Math.Cos( theta ) ),
                    ( float )( cy + cy * Math.Sin( theta ) ) );
                theta += dtheta;
                result[2 * i + 1] = new PointF(
                    ( float )( cx + cx * Math.Cos( theta ) * concave_radius ),
                    ( float )( cy + cy * Math.Sin( theta ) * concave_radius ) );
                theta += dtheta;
            }
            return result;
        }