示例#1
0
        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);
            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)
                    {
                        if (isCounterClockwise(newVec, new SimpleVector(x, y)) && !isCounterClockwise(oldVec, new SimpleVector(x, y)))
                        {
                            Target[x, y] = color;
                        }
                    }
                }
            }
            return(Target);
        }
示例#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);
            }
        }