//----------------------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------------------
        //Преобразование Фурье
        public Complex[] GetFourierTransform(
            double[] argumentValues, double[] functionValues, double[] frequencyValues
            )
        {
            int m = argumentValues.Length;

            //int count = argumentValues.Length * frequencyValues.Length;

            double[] realValues      = new double[frequencyValues.Length];
            double[] imaginaryValues = new double[frequencyValues.Length];

            for (int frequencyIndex = 0; frequencyIndex < frequencyValues.Length; frequencyIndex++)
            {
                double frequencyValue = frequencyValues[frequencyIndex];
                double realSum        = 0;
                double imaginarySum   = 0;
                for (int index = 0; index < argumentValues.Length; index++)
                {
                    double argumentValue = argumentValues[index];
                    double functionValue = functionValues[index];

                    //double phase = 2 * Math.PI * frequencyValue * argumentValue / m;
                    double phase = 2 * Math.PI * frequencyValue * argumentValue / m;
                    realSum      += functionValue * Math.Cos(phase);
                    imaginarySum -= functionValue * Math.Sin(phase);
                }

                realValues[frequencyIndex]      = realSum / m;
                imaginaryValues[frequencyIndex] = imaginarySum / m;
            }

            Complex[] resultValues = NumbersManager.CreateComplexNumbers(realValues, imaginaryValues);
            return(resultValues);
        }
        //-------------------------------------------------------------------------------------------
        //Ближайшая точка эллипса
        public Point2D GetNearestEllipsePoint(Point2D point)
        {
            double a = this.radiusX;
            double b = this.radiusY;

            double x = point.X;
            double y = point.Y;

            double a0 = (b * b * b * b * y * y) / (a * a);
            double a1 = 2 * b * b * (1 - (b * b) / (a * a)) * y;
            double a2 =
                a * a - 2 * b * b - x * x + (b * b * b * b) / (a * a) -
                (b * b * y * y) / (a * a);
            double a3 = 2 * ((b * b) / (a * a) - 1) * y;
            double a4 = -Math.Pow((a * a - b * b) / (a * b), 2);

            Complex[] roots        = QuarticEquation.GetRoots(a4, a3, a2, a1, a0);
            Complex[] integerRoots = NumbersManager.GetNumbersWithZeroImaginaryPart(roots);

            double[] coordinatesY = NumbersManager.GetRealParts(integerRoots);
            double[] coordinatesX = this.GetCoordinatesXOfPossiblePoints(point, coordinatesY);

            Point2D[] possiblePoints = PlaneManager.CreatePoints2D(coordinatesX, coordinatesY);
            Point2D[] ellipsePoints  = this.SelectPoints(possiblePoints, 0.01);

            Point2D nearestPoint = PlaneManager.GetNearestPoint(point, ellipsePoints);

            return(nearestPoint);
        }
Ejemplo n.º 3
0
        private void setDisplay(TimeSpan remainingTime)
        {
            clearDisplay();
            // colon is no longer needed in last minute
            if (remainingTime.TotalMinutes < 1)
            {
                ColonVisible = false;
            }
            Tuple <Number, Number, Number> numbers = NumbersManager.GetMSS(remainingTime);

            FirstNumber  = numbers.Item1;
            SecondNumber = numbers.Item2;
            ThirdNumber  = numbers.Item3;
        }
        //---------------------------------------------------------------------------------------------
        //Координаты x, соответствующие координате y
        public double[] GetCoordinatesX(double y)
        {
            double a = 1;
            double b = -2 * this.centre.X;
            double c =
                (y - this.centre.Y) * (y - this.centre.Y) +
                this.centre.X * this.centre.X -
                radius * radius;
            QuadraticEquation quadraticEquation = new QuadraticEquation(a, b, c);

            Complex[] complexRoots = quadraticEquation.GetRoots();
            double[]  realRoots    = NumbersManager.GetRealParts(complexRoots);
            return(realRoots);
        }
        //---------------------------------------------------------------------------------------------
        //Координаты y, соответствующие координате x
        public double[] GetCoordinatesY(double x)
        {
            double a = 1;
            double b = -2 * this.centre.Y;
            double c =
                (x - this.centre.X) * (x - this.centre.X) +
                this.centre.Y * this.centre.Y -
                radius * radius;

            //Complex[] complexRoots = QuadraticEquation.GetRoots( a, b, c );
            Complex[] complexRoots = ComplexQuadraticEquation.GetRoots(a, b, c);

            double[] realRoots = NumbersManager.GetRealParts(complexRoots);
            return(realRoots);
        }
Ejemplo n.º 6
0
        //-----------------------------------------------------------------------------------------------
        //Точки пересечения прямой и окружности
        public static Point2D[] IntersectionPointsOfLineAndCircle(
            LineDescriptor lineDescriptor,
            CircleDescriptor circleDescriptor
            )
        {
            double a = lineDescriptor.CoefficientOfX;
            double b = lineDescriptor.CoefficientOfY;
            double c = lineDescriptor.AbsoluteTerm;

            double xc = circleDescriptor.Centre.X;
            double yc = circleDescriptor.Centre.Y;
            double r  = circleDescriptor.Radius;

            double x1, x2, y1, y2;

            if (b != 0)
            {
                double koefficientA = 1 + ((a * a) / (b * b));
                double koefficientB = 2 * (c * a / (b * b) + yc * a / b - xc);
                double koefficientC =
                    xc * xc + yc * yc + (c * c) / (b * b) + 2 * yc * c / b - r * r;
                QuadraticEquation quadraticEquation =
                    new QuadraticEquation(koefficientA, koefficientB, koefficientC);

                Complex[] complexRoots = quadraticEquation.GetRoots();
                double[]  realRoots    = NumbersManager.GetRealParts(complexRoots);

                x1 = realRoots[0];
                y1 = (-c - a * x1) / b;
                x2 = realRoots[1];
                y2 = (-c - a * x2) / b;
            }
            else
            {
                double x = -c / a;
                x1 = x2 = x;
                double[] coordinatesY = circleDescriptor.GetCoordinatesY(x);
                y1 = coordinatesY[0];
                y2 = coordinatesY[1];
            }

            Point2D intersectionPoint1 = new Point2D(x1, y1);
            Point2D intersectionPoint2 = new Point2D(x2, y2);

            Point2D[] intersectionPoints = new Point2D[] { intersectionPoint1, intersectionPoint2 };

            return(intersectionPoints);
        }
 private void Start()
 {
     numbersManager = GameObject.FindWithTag("NumberManager").GetComponent <NumbersManager>();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// her bir test fonksiyonu için constructure çalışır ve dispğose ile dispose edilir.
 /// IDispose uygulanmmaış bile olsa default da xunit bu şekilde çalışır.
 /// Ancak
 /// </summary>
 public MyNumbersTest(ITestOutputHelper output)
 {
     _numbers          = new Dictionary <int, int>();
     _myNumbersManager = new NumbersManager(_numbers);
 }
Ejemplo n.º 9
0
 public void Awake()
 {
     instance = this;
 }