public void StartDraw()
        {
            var color = _form1.Options.FunState ? RandomColor(): _form1.BackColor;

            _form1.Options.GraphicsObject.Clear(color);


            var currentPoint   = new CoorinateFloat((float)_form1.Size.Width / 2, (float)_form1.Size.Height / 2);
            var centerOfCircle = new Point((int)currentPoint.X - 15, (int)currentPoint.Y - 15);
            var arrow          = new CustomArrow(currentPoint);

            //DrawFigure(arrow.Coordinates);
            DrawCircle(centerOfCircle);
            DrawBigCircle(currentPoint);


            var rotated1 = RotateFigure(arrow.Coordinates, new Point((int)currentPoint.X, (int)currentPoint.Y), _form1.Options.Angle1);

            _form1.DrawFigureFirstTask(rotated1, _form1.Options.MyPen1);
            _form1.Options.Angle1 = _form1.Options.Angle1 + _form1.Options.Step1;

            var rotated2 = RotateFigure(arrow.Coordinates, new Point((int)currentPoint.X, (int)currentPoint.Y), _form1.Options.Angle2);

            _form1.DrawFigureFirstTask(rotated2, _form1.Options.MyPen2);
            _form1.Options.Angle2 = _form1.Options.Angle2 + _form1.Options.Step2;

            var rotated3 = RotateFigure(arrow.Coordinates, new Point((int)currentPoint.X, (int)currentPoint.Y), _form1.Options.Angle3);

            _form1.DrawFigureFirstTask(rotated3, _form1.Options.MyPen3);
            _form1.Options.Angle3 = _form1.Options.Angle3 + _form1.Options.Step3;
        }
Esempio n. 2
0
        private List <CoorinateFloat> DrawPoints()
        {
            var centerPoint = new CoorinateFloat((float)Size.Width / 2, (float)Size.Height / 2);


            var coordinates = new List <CoorinateFloat>();

            var point = new CoorinateFloat(centerPoint);

            Brush aBrush = (Brush)Brushes.Black;

            for (var i = 0; i < dataGridView1.Rows.Count; i++)
            {
                var cellX = dataGridView1.Rows[i].Cells[0].Value;
                var cellY = dataGridView1.Rows[i].Cells[1].Value;
                if (cellX != null && cellY != null)
                {
                    var x = int.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString());
                    var y = int.Parse(dataGridView1.Rows[i].Cells[1].Value.ToString());
                    coordinates.Add(point.Coordinate(x, y));
                }
            }
            foreach (var dot in coordinates)
            {
                Options.GraphicsObject.FillRectangle(aBrush, dot.ForDrawX, dot.ForDrawY, 3, 3);
            }
            return(coordinates);
        }
Esempio n. 3
0
        public List <CoorinateFloat> Function2Task(CoorinateFloat centerPoint)
        {
            var goodWith   = Size.Width - OldSize.Width;
            var goodHeight = Size.Height - OldSize.Height;

            var haveA = float.TryParse(task2fromA.Text, out float a);
            var haveB = float.TryParse(task2toB.Text, out float b);
            var haveC = float.TryParse(task2constC.Text, out float c);

            var coordinates = new List <CoorinateFloat>();

            if (!haveA || !haveB || !haveC)
            {
                return(coordinates);
            }

            var dot = new CoorinateFloat(centerPoint);

            for (float i = a; i <= b; i = (float)Math.Round(i + 1f / 100f, 2))
            {
                if (i == 0 || (i + 1) == 0)
                {
                    coordinates.Add(dot.Coordinate(0, 0, true));
                }
                else
                {
                    var y = (c * (i * i) - 1) / (i + 1) + (1 / i) * 20;
                    var x = i * 20;
                    coordinates.Add(dot.Coordinate(x, y));
                }
            }

            return(coordinates);
        }
Esempio n. 4
0
        private void button4_Click(object sender, EventArgs e)
        {
            Options.GraphicsObject.Clear(DefaultBackColor);
            var currentPoint = new CoorinateFloat((float)Size.Width / 2, (float)Size.Height / 2);
            var coordsList   = Function2Task(currentPoint);

            DrawFigureTask2(coordsList, _options.MyPen1);
        }
        private void DrawBigCircle(CoorinateFloat centerOfCircle)
        {
            var ellipseSize = 480;
            var graphics    = _form1.CreateGraphics();
            var point       = new Point((int)centerOfCircle.X - ellipseSize / 2, (int)centerOfCircle.Y - ellipseSize / 2);
            var rectangle   = new Rectangle(point, new Size(ellipseSize, ellipseSize));

            graphics.DrawRectangle(_form1.Options.MyPen1, rectangle);
            graphics.DrawEllipse(_form1.Options.MyPen1, rectangle);
        }
        public CoorinateFloat Coordinate(float x, float y, bool isBadPoint = false)
        {
            var coord =
                new CoorinateFloat(x, y)
            {
                ForDrawX = x + _startCoordinates.X, ForDrawY = (-1) * y + _startCoordinates.Y, BadPoint = isBadPoint
            };

            return(coord);
        }
Esempio n. 7
0
        private static List <Vektor> GetVektors(List <CoorinateFloat> coordinates, CoorinateFloat firstPoint)
        {
            var vektorList = new List <Vektor>();

            foreach (var point in coordinates.Where(z => z != firstPoint))
            {
                var vektor = new Vektor(firstPoint, point);
                vektorList.Add(vektor);
            }
            return(vektorList);
        }
Esempio n. 8
0
        public CustomArrow(CoorinateFloat centerPoint)
        {
            var dot = new CoorinateFloat(centerPoint);

            Coordinates = new List <CoorinateFloat>()
            {
                dot.Coordinate(0, 10),
                dot.Coordinate(220, 10),
                dot.Coordinate(220, 20),
                dot.Coordinate(240, 0),
                dot.Coordinate(220, -20),
                dot.Coordinate(220, -10),
                dot.Coordinate(0, -10),
                dot.Coordinate(0, 10)
            };
        }
Esempio n. 9
0
        private static CoorinateFloat FindStartPoint(List <CoorinateFloat> coordinates)
        {
            var minCoordX      = coordinates.Min(z => z.X);
            var findFirstPoint = coordinates.Where(z => z.X == minCoordX);
            var firstPoint     = new CoorinateFloat(0, 0);

            if (findFirstPoint.Count() > 1)
            {
                var minY = findFirstPoint.Min(z => z.Y);
                firstPoint = findFirstPoint.FirstOrDefault(z => z.Y == minY);
            }
            else
            {
                firstPoint = findFirstPoint.FirstOrDefault();
            }
            return(firstPoint);
        }
Esempio n. 10
0
 public Vektor(CoorinateFloat f, CoorinateFloat s)
 {
     OX       = f.X - s.X;
     OY       = f.Y - s.Y;
     PointEnd = s;
 }
Esempio n. 11
0
        private static List <CoorinateFloat> SortedPointsByCos(List <CoorinateFloat> coordinates, CoorinateFloat firstPoint)
        {
            var vektorList     = GetVektors(coordinates, firstPoint);
            var verticalVektor = new Vektor(firstPoint, new CoorinateFloat(firstPoint.X, firstPoint.Y + 1));
            var sortedVektors  = vektorList.OrderByDescending(z => VektorOperation.Cosinus(verticalVektor, z)).Select(z => z.PointEnd).ToList();

            return(sortedVektors);
        }
Esempio n. 12
0
 public CoorinateFloat(CoorinateFloat startCoordinates)
 {
     _startCoordinates = startCoordinates;
 }