Пример #1
0
        public void RemoveElementTest()
        {
            var tmpInterp = new InterpXY();

            tmpInterp.Add(1, 1);
            tmpInterp.Add(2, 1);
            tmpInterp.Add(3, 1);
            tmpInterp.RemoveElement(0);
            Assert.AreEqual(2, tmpInterp.Count);
            Assert.AreEqual(2, tmpInterp.Count);
            Assert.AreEqual(2, tmpInterp.Count);
        }
Пример #2
0
        public void RepeatShiftTest2()
        {
            var interp = new InterpXY();

            interp.Add(-1, 0);
            interp.Add(1, 2);
            interp.Add(2, 2);
            interp.ET_right = ExtrapolType.etRepeat;
            interp.ET_left  = ExtrapolType.etRepeat;

            Assert.AreEqual(1.0, interp[-3], 0.0001);
            Assert.AreEqual(1.0, interp[3], 0.0001);
            Assert.AreEqual(0.5, interp[5.5], 0.0001);
            Assert.AreEqual(2.0, interp[4.5], 0.0001);
            Assert.AreEqual(0, interp[-4.0], 0.0001);
        }
Пример #3
0
        public static InterpXY RectangleImpulse(double t1)
        {
            var res = new InterpXY();

            res.ET_left    = ExtrapolType.etRepeat;
            res.ET_right   = ExtrapolType.etRepeat;
            res.InterpType = InterpolType.itStep;
            if (t1 >= 1d)
            {
                res.Add(0d, 1d);
                res.Add(1d, 1d);
                return(res);
            }
            res.Add(0d, 1d);
            res.Add(t1, 0d);
            res.Add(1d, 0d);
            return(res);
        }
Пример #4
0
        public virtual InterpXY GetInterpSignal(IEnumerable <double> pointsTime)
        {
            var res = new InterpXY();

            foreach (var t in pointsTime)
            {
                res.Add(t, GetAmp(t));
            }
            return(res);
        }
Пример #5
0
        public InterpXY GetInterp(double fromT, double toT)
        {
            var    res = new InterpXY();
            double t   = fromT;

            while (t < toT)
            {
                res.Add(t, Random.GetNorm(Func(t), SKOx3_Funct(t) / 3));
                double currShag;
                do
                {
                    currShag = Random.GetNorm(Shag, SKOx3dT / 3);
                } while(currShag <= 0);
                t += Shag;
            }
            t = toT;
            res.Add(t, Random.GetNorm(Func(t), SKOx3_Funct(t) / 3));
            return(res);
        }
Пример #6
0
        public void AddElementTest()
        {
            sInterp1elem = new InterpXY();
            sInterp2elem = new InterpXY();
            sInterp5elem = new InterpXY();

            sInterp1elem.Add(3, 3);
            Assert.AreEqual(1, sInterp1elem.Count);

            sInterp2elem.Add(1, 1);
            sInterp2elem.Add(4, 4);
            Assert.AreEqual(2, sInterp2elem.Count);

            sInterp5elem.Add(-1, -2);
            sInterp5elem.Add(0, 0);
            sInterp5elem.Add(1, -1);
            sInterp5elem.Add(5, 1);
            sInterp5elem.Add(10, 7);
            Assert.AreEqual(5, sInterp5elem.Count);
        }
Пример #7
0
        public static InterpXY TrapecImpulse(double t1, double t2, double t3)
        {
            var max = Math.Max(t1, Math.Max(t2, t3));

            if (max >= 1d)
            {
                t1 /= max;
                t2 /= max;
                t3 /= max;
            }
            var res = new InterpXY();

            res.ET_left  = ExtrapolType.etRepeat;
            res.ET_right = ExtrapolType.etRepeat;
            res.Add(0d, 0d);
            res.Add(t1, 1d);
            res.Add(t2, 1d);
            res.Add(t3, 0d);
            res.Add(1d, 0d);
            return(res);
        }
Пример #8
0
        public override InterpXY GetInterpSignal(IEnumerable <double> pointsTime)
        {
            var res = new InterpXY();

            InterpHz = GenerateNewHzFunct || InterpHz == null?s_rnd.GetInterp(pointsTime.Min(), pointsTime.Max()) : InterpHz;


            foreach (var t in pointsTime)
            {
                res.Add(t, GetAmp(t, InterpHz[t]));
            }
            return(res);
        }
Пример #9
0
        public static InterpXY SinImpulse(int nPoints = 1000)
        {
            var res = new InterpXY();

            res.ET_left  = ExtrapolType.etRepeat;
            res.ET_right = ExtrapolType.etRepeat;
            double dt = 1d / nPoints;
            double t  = 0d;

            for (int i = 0; i < nPoints; i++)
            {
                res.Add(t, Math.Sin(t * (2 * Math.PI)));
                t += dt;
            }
            return(res);
        }
Пример #10
0
        public void RepeatShiftTest()
        {
            var interp = new InterpXY();

            interp.Add(1.5, 0);
            interp.Add(2, 0);
            interp.Add(3, 0);

            double sh = 6.5;

            interp.RepeatShift(ref sh);
            Assert.AreEqual(2.0, sh, 0.0001);

            sh = 2.0;
            interp.RepeatShift(ref sh);
            Assert.AreEqual(2.0, sh, 0.0001);

            sh = -5.0;
            interp.RepeatShift(ref sh);
            Assert.AreEqual(2.5, sh, 0.0001);

            sh = -3.0;
            interp.RepeatShift(ref sh);
            Assert.AreEqual(1.5, sh, 0.0001);

            sh = 0.0;
            interp.RepeatShift(ref sh);
            Assert.AreEqual(1.5, sh, 0.0001);

            interp.Data.Clear();
            interp.Add(-1.5, 0);
            interp.Add(-2, 0);
            interp.Add(-3, 0);

            sh = -5.0;
            interp.RepeatShift(ref sh);
            Assert.AreEqual(-2.0, sh, 0.0001);

            sh = -3.0;
            interp.RepeatShift(ref sh);
            Assert.AreEqual(-3.0, sh, 0.0001);

            sh = -1.0;
            interp.RepeatShift(ref sh);
            Assert.AreEqual(-2.5, sh, 0.0001);

            sh = 0.0;
            interp.RepeatShift(ref sh);
            Assert.AreEqual(-3.0, sh, 0.0001);

            sh = 2.0;
            interp.RepeatShift(ref sh);
            Assert.AreEqual(-2.5, sh, 0.0001);
        }
Пример #11
0
        public void ResizeTime(double mnozj)
        {
            var nwX = new InterpXY();

            foreach (var xs in X.Data)
            {
                nwX.Add(xs.Key * mnozj, xs.Value.Value);
            }
            X.Dispose();
            X = nwX;

            var nwY = new InterpXY();

            foreach (var ys in Y.Data)
            {
                nwY.Add(ys.Key * mnozj, ys.Value.Value);
            }
            Y.Dispose();
            Y = nwY;
        }
Пример #12
0
        public double Get_kt_I_shtr(double mach, double alpha)
        {
            double lmbda_nos;

            if (Body.Nose is RocketNos_ConePlusCyl)
            {
                lmbda_nos = Body.Lmb_nos;
            }
            else
            {
                double   cx_nos    = Body.Cx_nose(mach);
                InterpXY lmb_ot_Cx = new InterpXY();
                foreach (var item in (AeroGr.Graphs["4_11"] as Interp2D)._data)
                {
                    double lmb    = item.Key;
                    double cx_tmp = item.Value.GetV(mach);
                    lmb_ot_Cx.Add(cx_tmp, lmb);
                }
                lmbda_nos = lmb_ot_Cx.GetV(cx_nos);
            }
            return(AeroGr.GetV("3_21", lmbda_nos, mach));
        }