Beispiel #1
0
        public async Task checkMeshGrid(double[] theta1Vector, double[] theta2Vector)
        {
            var fuzzyHelper = new FuzzyHelper();
            var result      = await fuzzyHelper.MeshGrid(theta1Vector, theta2Vector);

            result.ShouldNotBeNull();
            result.Count().ShouldBe(2);
            var g  = (result.ToList()[0]);
            var g1 = (result.ToList()[1]);

            g[1, 1].ShouldBe(2);
            g[1, 2].ShouldBe(3);
            g1[1, 1].ShouldBe(2);
            g1[1, 2].ShouldBe(2);
        }
Beispiel #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);
        }