Exemplo n.º 1
0
        public int DeterminateDTA(double angle)
        {
            int result = 0;

            /*
             *  верхняя часть: 0-27.5 - 0; 17.5-72.5 - 1; 62.5-117.5 - 2; 107.5-162.5 - 3; 152.5-180 - 4;
             *  нижняя часть: 180-207.5 - -1; 197.5-252.5 - -2; 242.5-297.5 - -3; 287.5-342.5 - -4; 332.5-360 - -5;
             */
            double[] tr_arr = new double[5];
            if (angle >= 0 && angle <= 180)
            {
                double l = -27.5, r = l + 55;
                tr_arr[0] = MathApparat.yTriangleHalf(0, 27.5, angle);
                for (int i = 1; i < 4; i++)
                {
                    l        += 45;
                    r         = l + 55;
                    tr_arr[i] = MathApparat.yTrianglePos(l, (l + r) / 2, r, angle);
                    if (tr_arr[i] > tr_arr[i - 1])
                    {
                        result = i;
                    }
                }
                tr_arr[4] = MathApparat.yTriangleHalf(152.5, 180, angle);
                if (tr_arr[4] > tr_arr[3])
                {
                    result = 4;
                }
            }
            if (angle > 180 && angle < 360)
            {
                double l = 152.5, r = l + 55;
                result    = -1;
                tr_arr[0] = MathApparat.yTriangleHalf(180, 207.5, angle);
                for (int i = 1; i < 4; i++)
                {
                    l        += 45;
                    r         = l + 55;
                    tr_arr[i] = MathApparat.yTrianglePos(l, (l + r) / 2, r, angle);
                    if (tr_arr[i] > tr_arr[i - 1])
                    {
                        result = -i - 1;
                    }
                }
                tr_arr[4] = MathApparat.yTriangleHalf(332.5, 360, angle);
                if (tr_arr[4] > tr_arr[3])
                {
                    result = -5;
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public int DeterminateDTS(double speed)
        {
            int type = 0;

            // 0 - нулевая;
            // 1 - положительная низкая;
            // 2 - положительная высокая;
            // -1 - отрицательная низкая;
            // -2 - отрицательная высокая;
            double[] tr_arr = new double[3];
            if (speed > 0)
            {
                tr_arr[0] = MathApparat.yTriangleHalf(0, 15, speed);
                double l = -5, r = 15;
                for (int i = 1; i < 3; i++)
                {
                    l        += 15;
                    r        += 15;
                    tr_arr[i] = MathApparat.yTrianglePos(l, (l + r) / 2, r, speed);
                    if (tr_arr[i] > tr_arr[i - 1])
                    {
                        type = i;
                    }
                }
            }
            if (speed < 0)
            {
                tr_arr[0] = MathApparat.yTriangleHalf(-15, 0, speed);
                int l = 5, r = -15;
                for (int i = 1; i < 3; i++)
                {
                    l        -= 15;
                    r        -= 15;
                    tr_arr[i] = MathApparat.yTriangleNeg(l, (l + r) / 2, r, speed);
                    if (tr_arr[i] > tr_arr[i - 1])
                    {
                        type = -i;
                    }
                }
            }
            if (speed == 45)
            {
                type = 2;
            }
            if (speed == -45)
            {
                type = -2;
            }
            return(type);
        }