Exemplo n.º 1
0
 public ringBuffer()
 {
     data = new vector3d[SIZE];
     for (int i = 0; i < SIZE; i++)
     {
         data[i] = new vector3d();
     }
 }
Exemplo n.º 2
0
        public vector3d[] getCopy()
        {
            vector3d[] copy = new vector3d[SIZE];
            int        h    = head;

            for (int i = 0; i < SIZE; i++)
            {
                copy[i] = data[h++];
                h      %= SIZE;
            }
            return(copy);
        }
Exemplo n.º 3
0
        static void dataRecived(object sender, SerialDataReceivedEventArgs e)
        {
            lock (srp)
            {
                if (IGNORE)
                {
                    while (srp.BytesToRead > 0)
                    {
                        srp.ReadByte();
                    }
                    return;
                }
                while (srp.ReadByte() != 0xff)
                {
                    ;
                }
                while (srp.BytesToRead < 12)
                {
                    ;
                }
                // while (srp.BytesToRead > 11)
                lock (stk)
                {
                    vector3d V    = new vector3d();
                    byte[]   data = new byte[12];
                    srp.Read(data, 0, 12);
                    V.x  = BitConverter.ToSingle(data, 0);
                    V.y  = BitConverter.ToSingle(data, 4);
                    V.z  = BitConverter.ToSingle(data, 8);
                    V.x /= 1600;
                    V.y /= 1600;
                    V.z /= 1600;

                    stk.add(V);

                    if (!SIGNAL && !READY_READ && (abs(V.x) > 2.3 || abs(V.y) > 2.3 || abs(V.z) > 2.3))
                    {
                        SO_POWERFUL = false;
                        SIGNAL      = true;
                        Co          = 0;
                    }
                    if (SIGNAL)
                    {
                        if (abs(V.x) > 9 || abs(V.y) > 9 || abs(V.z) > 9)
                        {
                            SO_POWERFUL = true;
                        }
                        Co += 1;
                        if (Co >= 71)
                        {
                            READY_READ = true && !SO_POWERFUL;
                            if (collecting.Checked)
                            {
                                IGNORE = READY_READ;
                            }
                            SIGNAL = false;
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
 static double hypot(vector3d V)
 {
     return(Math.Sqrt(V.x * V.x + V.y * V.y + V.z * V.z));
 }
Exemplo n.º 5
0
 public void add(vector3d vec)
 {
     data[head++] = vec;
     head        %= SIZE;
 }