Exemplo n.º 1
0
        //draw pie slice
        public static ARGB[,] DrawSlice(ARGB[,] Target, double startangle, double angletodraw, ARGB color)
        {
            int          sizepiechart = Target.GetLength(0);
            SimpleVector oldVec, newVec;

            oldVec   = new SimpleVector();
            newVec   = new SimpleVector();
            newVec.x = Math.Cos(angletodraw);
            newVec.y = Math.Sin(angletodraw);
            oldVec.x = Math.Cos(startangle);
            oldVec.y = Math.Sin(startangle);
            SimpleVector point;

            for (int x = 0; x < sizepiechart; x++)
            {
                for (int y = 0; y < sizepiechart; y++)
                {
                    if (Math.Sqrt(Math.Pow(x - sizepiechart / 2, 2) + Math.Pow(y - sizepiechart / 2, 2)) < sizepiechart / 2)
                    {
                        point = new SimpleVector(x - sizepiechart / 2, y - sizepiechart / 2);
                        if (isCounterClockwise(newVec, point) && !isCounterClockwise(oldVec, point))
                        {
                            Target[x, y] = color;
                        }
                    }
                }
            }
            return(Target);
        }
Exemplo n.º 2
0
        public static bool isCounterClockwise(SimpleVector line, SimpleVector point)
        {
            SimpleVector normal     = new SimpleVector(-line.y, line.x);
            double       projection = point.x * line.x + point.y * line.y;

            if (projection >= 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }