private static int GetNewCorrection(Point nextPoint, PotentialsFunction result, int nextClassNumber)
        {
            var functionValue = result.GetValue(nextPoint);

            if (functionValue <= 0 && nextClassNumber == 0)
            {
                return(1);
            }

            return(functionValue > 0 && nextClassNumber == 1 ? -1 : 0);
        }
Example #2
0
        private void testButton_Click(object sender, EventArgs e)
        {
            var testPoint   = new Point((int)testXNumericUpDown.Value, (int)testYNumericUpDown.Value);
            var classNumber = _separetFunction.GetValue(testPoint) >= 0 ? 0 : 1;
            var bitmap      = new Bitmap(pictureBox.Image);

            _points[classNumber].Add(testPoint);
            testTextBox.Text = $@"Класс {classNumber + 1}";
            pictureBox.Image.Dispose();

            using (var graphics = Graphics.FromImage(bitmap))
            {
                DrawPoint(graphics, testPoint, classNumber);
            }

            pictureBox.Image = bitmap;
        }