Ejemplo n.º 1
0
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            var vm = DataContext as MainViewModel;

            vm.Model1.Series.Clear();
            var rndF = new RndFunction(t => Math.Cos(t), t => Math.Sin(t) / 5, 0.01, 0.01);

            for (int i = 0; i < 1; i++)
            {
                var ser = new LineSeries();
                foreach (var point in rndF.GetInterp(0, 10).Points())
                {
                    ser.Points.Add(new DataPoint(point.X, point.Y));
                }
                vm.Model1.Series.Add(ser);
            }
            vm.Model1.InvalidatePlot(false);
        }
Ejemplo n.º 2
0
        public void SynchModels(double resizeMnozj, double cameraHz, double dcameraHz)
        {
            Coords = GetTrueCoordsList(resizeMnozj);
            if (Signals.Count != 4)
            {
                throw new Exception("Загрузи сигналы!");
            }
            var timeMaxSeq = from crds in Coords
                             select crds.X.Data.Keys.Max();

            var timeMax = timeMaxSeq.Max();

            double t_shagAver = 0.5 / (cameraHz - dcameraHz) + 0.5 / (cameraHz + dcameraHz);
            double delta_shag = 0.5 / (cameraHz - dcameraHz) - 0.5 / (cameraHz + dcameraHz);

            TimeMoments = new List <double>((int)(timeMax * (cameraHz + dcameraHz) + 7));
            var rndFunct   = new RndFunction(t => t, 0, t_shagAver, delta_shag);
            var timeInterp = rndFunct.GetInterp(0, timeMax);

            TimeMoments = new List <double>(timeInterp.Data.Keys);


            SignalsInterp = new List <InterpXY>(4);
            for (int i = 0; i < 4; i++)
            {
                Signals[i].Reset();
                SignalsInterp.Add(Signals[i].GetInterpSignal(TimeMoments));
            }

            ReceivedPoints = new List <List <Vector?> >(TimeMoments.Capacity);
            for (int i = 0; i < TimeMoments.Count; i++)
            {
                ReceivedPoints.Add(new List <Vector?>(4));
                for (int j = 0; j < 4; j++)
                {
                    if (SignalsInterp[j][TimeMoments[i]] > 0.1)
                    {
                        ReceivedPoints[i].Add(Coords[j].Getpoint(TimeMoments[i]));
                    }
                    else
                    {
                        ReceivedPoints[i].Add(null);
                    }
                }
            }

            var trp = ReceivedPoints.
                      Select(lv => {
                var notNull = lv.Where(v => v.HasValue).Select(v => v.Value).ToList();

                var distMatr = new bool[notNull.Count, notNull.Count];
                for (int i = 0; i < notNull.Count; i++)
                {
                    for (int j = i + 1; j < notNull.Count; j++)
                    {
                        distMatr[i, j] = (notNull[i] - notNull[j]).Length < UnityRadius;
                        distMatr[j, i] = distMatr[i, j];
                    }
                }

                var alreadyUnityP = new List <int>(notNull.Count);
                var res           = new List <Vector>(4);
                for (int i = 0; i < notNull.Count; i++)
                {
                    if (alreadyUnityP.Contains(i))
                    {
                        continue;
                    }
                    var closeP = new List <int>(notNull.Count);

                    Action <int> recurce = null;
                    recurce = new Action <int>((nearMe) => {
                        closeP.Add(nearMe);
                        for (int k = 0; k < notNull.Count; k++)
                        {
                            if (distMatr[nearMe, k] && !closeP.Contains(k))
                            {
                                recurce(k);
                            }
                        }
                    });

                    recurce(i);
                    alreadyUnityP.AddRange(closeP);
                    alreadyUnityP = alreadyUnityP.Distinct().ToList();
                    if (closeP.Count > 2)
                    {
                        int ss = 1;
                    }
                    //var resP = notNull[closeP[0]];
                    //for(int j = 1; j< closeP.Count; j++) {
                    //    resP += notNull[closeP[j]];
                    //}
                    //resP /= closeP.Count + 1;
                    var resP = closeP.Aggregate(new Vector(), (vec, k) => vec += notNull[k], (vec) => vec /= closeP.Count);
                    res.Add(resP);
                }

                return(res);
            });

            ReceivedPointsTrue = new List <List <Vector> >(TimeMoments.Capacity);
            foreach (var rp in trp)
            {
                ReceivedPointsTrue.Add(rp);
            }

            RedrawModel4();
        }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="hz0"></param>
 /// <param name="deltaHz">+ -</param>
 /// <param name="name"></param>
 public FuzzySignal(double hz0, double deltaHz, string name = "") : base(hz0, name)
 {
     s_rnd  = new RndFunction(t => Hz0, deltaHz, 1d / Hz0, 0.7d / Hz0);
     Shift0 = s_rnd.Random.GetDouble();
     Shift  = Shift0;
 }