Пример #1
0
        public async Task checkStrategyOfCalculationCoordinates(double l1, double l2)
        {
            var fuzzyHelper = new FuzzyHelper();
            var temp        = new List <double[, ]>();
            var temp1       = new double[2, 3] {
                { 1, 2, 3 }, { 1, 2, 3 }
            };
            var temp2 = new double[2, 3] {
                { 1, 1, 1 }, { 2, 2, 2 }
            };

            temp.Add(temp1);
            temp.Add(temp2);
            var result = await fuzzyHelper.CalculateCoordinates(l1, l2, temp);
        }
Пример #2
0
        public async Task <bool> CalculateWholeDataSet(double agleStep)
        {
            try {
                var calculateVector1Task = _fuzzyHelper.CalculateVector(Theta1Min, Theta1Max, agleStep);
                var calculateVector2Task = _fuzzyHelper.CalculateVector(Theta2Min, Theta2Max, agleStep);

                Theta1Vector = await calculateVector1Task;
                Theta2Vector = await calculateVector2Task;

                if (Theta1Vector == null || !Theta1Vector.Any())
                {
                    throw new Exception("Theta1Max Vector is empty.");
                }
                if (Theta2Vector == null || !Theta2Vector.Any())
                {
                    throw new Exception("Theta2Max Vector is empty.");
                }

                AnglesGrid = await _fuzzyHelper.MeshGrid(Theta1Vector, Theta2Vector);

                if (AnglesGrid == null)
                {
                    throw new Exception("MeshGrid function not working");
                }

                var coordinates = await _fuzzyHelper.CalculateCoordinates(L1, L2, AnglesGrid);

                X2D = coordinates.ToArray()[0];
                Y2D = coordinates.ToArray()[1];

                var t1 = Task.Run(() => X.ToList());
                var t2 = Task.Run(() => Y.ToList());

                Task.WaitAll(t1, t2);
                Positions = X.Select((t, i) => new Point {
                    X = t, Y = Y[i], Z = 0
                }).ToList();
                IsDataSetCalculated = true;

                return(true);
            } catch (Exception e) {
                Trace.WriteLine(e);
            }
            return(false);
        }