Exemplo n.º 1
0
        public void draw(double xCenter, double yCenter, double Radius, double startAngle, double endAngle, string Tag)
        {
            double
                xStart       = xCenter + Radius * Math.Cos(Draw.DegToRad(startAngle)),
                yStart       = yCenter + Radius * Math.Sin(-Draw.DegToRad(startAngle));
            bool changeAngle = true;

            while (changeAngle)
            {
                if (startAngle < endAngle)
                {
                    for (double i = startAngle; i <= endAngle; i++)
                    {
                        Calculate(xCenter, yCenter, ref xStart, ref yStart, Radius, i);
                    }
                    changeAngle = false;
                }
                else
                {
                    for (double i = startAngle; i >= endAngle && i <= 360; i++)
                    {
                        Calculate(xCenter, yCenter, ref xStart, ref yStart, Radius, i);
                    }
                    startAngle = 0;
                }
            }
        }
Exemplo n.º 2
0
        private void Calculate(double xCenter, double yCenter, ref double xStart, ref double yStart, double Radius, double i)
        {
            double
                x = xCenter + Radius * Math.Cos(Draw.DegToRad(i)),
                y = yCenter + Radius * Math.Sin(-Draw.DegToRad(i));

            Line.Draw(xStart, yStart, x, y, 3, "Black", "Drawing");

            xStart = x;
            yStart = y;
        }
Exemplo n.º 3
0
        private void Rotate(double x0, double y0, double degree)
        {
            double x1, y1, x2, y2;

            degree = -degree;
            y0     = height - y0;

            foreach (Line line in canvas.Children)
            {
                if (line.Tag.ToString() == "Drawing")
                {
                    x1 = line.X1;
                    y1 = line.Y1;
                    x2 = line.X2;
                    y2 = line.Y2;

                    line.X1 = x0 + (x1 - x0) * Math.Cos(Draw.DegToRad(degree)) - (y1 - y0) * Math.Sin(Draw.DegToRad(degree));
                    line.Y1 = y0 + (x1 - x0) * Math.Sin(Draw.DegToRad(degree)) + (y1 - y0) * Math.Cos(Draw.DegToRad(degree));
                    line.X2 = x0 + (x2 - x0) * Math.Cos(Draw.DegToRad(degree)) - (y2 - y0) * Math.Sin(Draw.DegToRad(degree));
                    line.Y2 = y0 + (x2 - x0) * Math.Sin(Draw.DegToRad(degree)) + (y2 - y0) * Math.Cos(Draw.DegToRad(degree));
                }
            }
        }