getMinAcceleration() public method

public getMinAcceleration ( ) : double
return double
Esempio n. 1
0
        /**
         * Trains this Quantizer with a specific gesture. This means that the
         * positions of the centeroids would adapt to this training gesture. In our
         * case this would happen with a summarized virtual gesture, containing all
         * the other gestures.
         *
         * @param gesture
         *            the summarized virtual gesture
         */
        public void trainCenteroids(Gesture gesture)
        {
            List <AccelerationVector> data = gesture.getData();
            double pi = Math.PI;

            this.radius = (gesture.getMaxAcceleration() + gesture.getMinAcceleration()) / 2;

            // x , z , y
            if (!this.maptrained)
            {
                this.maptrained = true;
                this.map[0]     = new double[] { this.radius, 0.0, 0.0 };
                this.map[1]     = new double[] { Math.Cos(pi / 4) * this.radius, 0.0,
                                                 Math.Sin(pi / 4) * this.radius };
                this.map[2] = new double[] { 0.0, 0.0, this.radius };
                this.map[3] = new double[] { Math.Cos(pi * 3 / 4) * this.radius,
                                             0.0, Math.Sin(pi * 3 / 4) * this.radius };
                this.map[4] = new double[] { -this.radius, 0.0, 0.0 };
                this.map[5] = new double[] { Math.Cos(pi * 5 / 4) * this.radius,
                                             0.0, Math.Sin(pi * 5 / 4) * this.radius };
                this.map[6] = new double[] { 0.0, 0.0, -this.radius };
                this.map[7] = new double[] { Math.Cos(pi * 7 / 4) * this.radius,
                                             0.0, Math.Sin(pi * 7 / 4) * this.radius };

                this.map[8] = new double[] { 0.0, this.radius, 0.0 };
                this.map[9] = new double[] { 0.0, Math.Cos(pi / 4) * this.radius,
                                             Math.Sin(pi / 4) * this.radius };
                this.map[10] = new double[] { 0.0,
                                              Math.Cos(pi * 3 / 4) * this.radius,
                                              Math.Sin(pi * 3 / 4) * this.radius };
                this.map[11] = new double[] { 0.0, -this.radius, 0.0 };
                this.map[12] = new double[] { 0.0,
                                              Math.Cos(pi * 5 / 4) * this.radius,
                                              Math.Sin(pi * 5 / 4) * this.radius };
                this.map[13] = new double[] { 0.0,
                                              Math.Cos(pi * 7 / 4) * this.radius,
                                              Math.Sin(pi * 7 / 4) * this.radius };
            }

            int[,] g_alt = new int[this.map.Length, data.Count];
            int[,] g     = new int[this.map.Length, data.Count];

            do
            {
                // Derive new Groups...
                g_alt = this.copyarray(g);
                g     = this.deriveGroups(gesture);

                // calculate new centeroids
                for (int i = 0; i < this.map.GetLength(0); i++)
                {
                    double zaehlerX = 0;
                    double zaehlerY = 0;
                    double zaehlerZ = 0;
                    int    nenner   = 0;
                    for (int j = 0; j < data.Count; j++)
                    {
                        if (g[i, j] == 1)
                        {
                            var e = data[j];
                            zaehlerX += e.X;
                            zaehlerY += e.Y;
                            zaehlerZ += e.Z;
                            nenner++;
                        }
                    }
                    if (nenner > 1) // nur wenn der nenner>0 oder >1??? ist muss
                                    // was
                    // geaendert werden
                    // Log.write("Setze neuen Centeroid!");
                    {
                        this.map[i] = new double[] { (zaehlerX / (double)nenner),
                                                     (zaehlerY / (double)nenner),
                                                     (zaehlerZ / (double)nenner) };
                        // Log.write("Centeroid: "+i+": "+newcenteroid[0]+":"+newcenteroid[1]);
                    }
                } // new centeroids
            } while (!equalarrays(g_alt, g));

            // Debug: Printout groups

            /*
             * for (int i = 0; i < n; i++) { for (int j = 0; j < this.data.Count;
             * j++) { Log.write(g[i][j] + "|"); } Log.write(""); }
             */
        }
Esempio n. 2
0
        /**
         * Trains this Quantizer with a specific gesture. This means that the
         * positions of the centeroids would adapt to this training gesture. In our
         * case this would happen with a summarized virtual gesture, containing all
         * the other gestures.
         *
         * @param gesture
         *            the summarized virtual gesture
         */
        public void trainCenteroids(Gesture gesture)
        {
            List<AccelerationVector> data = gesture.getData();
            double pi = Math.PI;
            this.radius = (gesture.getMaxAcceleration() + gesture.getMinAcceleration()) / 2;

            // x , z , y
            if (!this.maptrained) {
            this.maptrained = true;
            this.map[0] = new double[] { this.radius, 0.0, 0.0 };
            this.map[1] = new double[] { Math.Cos(pi / 4) * this.radius, 0.0,
                    Math.Sin(pi / 4) * this.radius };
            this.map[2] = new double[] { 0.0, 0.0, this.radius };
            this.map[3] = new double[] { Math.Cos(pi * 3 / 4) * this.radius,
                    0.0, Math.Sin(pi * 3 / 4) * this.radius };
            this.map[4] = new double[] { -this.radius, 0.0, 0.0 };
            this.map[5] = new double[] { Math.Cos(pi * 5 / 4) * this.radius,
                    0.0, Math.Sin(pi * 5 / 4) * this.radius };
            this.map[6] = new double[] { 0.0, 0.0, -this.radius };
            this.map[7] = new double[] { Math.Cos(pi * 7 / 4) * this.radius,
                    0.0, Math.Sin(pi * 7 / 4) * this.radius };

            this.map[8] = new double[] { 0.0, this.radius, 0.0 };
            this.map[9] = new double[] { 0.0, Math.Cos(pi / 4) * this.radius,
                    Math.Sin(pi / 4) * this.radius };
            this.map[10] = new double[] { 0.0,
                    Math.Cos(pi * 3 / 4) * this.radius,
                    Math.Sin(pi * 3 / 4) * this.radius };
            this.map[11] = new double[] { 0.0, -this.radius, 0.0 };
            this.map[12] = new double[] { 0.0,
                    Math.Cos(pi * 5 / 4) * this.radius,
                    Math.Sin(pi * 5 / 4) * this.radius };
            this.map[13] = new double[] { 0.0,
                    Math.Cos(pi * 7 / 4) * this.radius,
                    Math.Sin(pi * 7 / 4) * this.radius };
            }

            int[,] g_alt = new int[this.map.Length, data.Count];
            int[,] g = new int[this.map.Length, data.Count];

            do {
            // Derive new Groups...
            g_alt = this.copyarray(g);
            g = this.deriveGroups(gesture);

            // calculate new centeroids
            for (int i = 0; i < this.map.GetLength(0); i++) {
                double zaehlerX = 0;
                double zaehlerY = 0;
                double zaehlerZ = 0;
                int nenner = 0;
                for (int j = 0; j < data.Count; j++) {
                    if (g[i,j] == 1) {
                        var e = data[j];
                        zaehlerX += e.X;
                        zaehlerY += e.Y;
                        zaehlerZ += e.Z;
                        nenner++;
                    }
                }
                if (nenner > 1) { // nur wenn der nenner>0 oder >1??? ist muss
                                    // was
                    // geaendert werden
                    // Log.write("Setze neuen Centeroid!");
                    this.map[i] = new double[] {(zaehlerX / (double) nenner),
                                                (zaehlerY / (double) nenner),
                                                (zaehlerZ / (double) nenner) };
                    // Log.write("Centeroid: "+i+": "+newcenteroid[0]+":"+newcenteroid[1]);
                }
            } // new centeroids

            } while (!equalarrays(g_alt, g));

            // Debug: Printout groups
            /*
             * for (int i = 0; i < n; i++) { for (int j = 0; j < this.data.Count;
             * j++) { Log.write(g[i][j] + "|"); } Log.write(""); }
             */
        }