Esempio n. 1
0
        /// <summary> 加速度の変化量 </summary>
        private void GetDeltaAccList()
        {
            InitParameter();

            float[] p0 = new float[] { jointsList[0][JointType], jointsList[0][JointType + 1], jointsList[0][JointType + 2] };
            double  v0 = 0;
            double  a0 = 0;

            for (int i = 1; i < timeTable.Count; i++)
            {
                float[] joint = jointsList[i];
                int     t     = timeTable[i] - timeTable[i - 1];
                double  v     = Caliculater.GetVelocity(joint, JointType, p0, t);
                double  a     = (v - v0) / t;
                double  delA  = (a - a0) / t;
                if (i < 3)
                {
                    delA = 0;
                }
                if (timeTable[i] > 19500)
                {
                    delA = 0;
                }
                UpdateMaxMin(delA);
                v0 = v;
                a0 = a;
                datapointList[i] = new DataPoint(timeTable[i], delA);
            }
            UpdateView();
        }
Esempio n. 2
0
 /// <summary> 手肘肩の角度 全開で2,3前後の値 </summary>
 private void GetAngleList()
 {
     InitParameter();
     for (int i = 0; i < timeTable.Count; i++)
     {
         double angle = Caliculater.GetAngle(jointsList[i], anglePoint[0], anglePoint[1], anglePoint[2]);
         UpdateMaxMin(angle);
         datapointList[i] = new DataPoint(timeTable[i], angle);
     }
     UpdateView();
 }
Esempio n. 3
0
        /// <summary> 角速度 </summary>
        private void GetAngularVelocityList()
        {
            InitParameter();
            double angle0 = 0;

            datapointList[0] = new DataPoint(timeTable[0], 0);
            for (int i = 1; i < timeTable.Count; i++)
            {
                double angle     = Caliculater.GetAngle(jointsList[i], anglePoint[0], anglePoint[1], anglePoint[2]);
                double aVelocity = (angle - angle0) / (timeTable[i] - timeTable[i - 1]);
                if (timeTable[i] < 2000)
                {
                    aVelocity = 0;
                }
                UpdateMaxMin(aVelocity);
                datapointList[i] = new DataPoint(timeTable[i], aVelocity);
                angle0           = angle;
            }
            UpdateView();
        }
Esempio n. 4
0
        /// <summary> 速度 </summary>
        private void GetVelocityList()
        {
            InitParameter();
            float[] p0 = new float[] { jointsList[0][JointType], jointsList[0][JointType + 1], jointsList[0][JointType + 2] };
            datapointList[0] = new DataPoint(timeTable[0], 0);
            for (int i = 1; i < timeTable.Count; i++)
            {
                var    joint    = jointsList[i];
                double velocity = Caliculater.GetVelocity(joint, JointType, p0, (timeTable[i] - timeTable[i - 1]));

                if (i < 10)
                {
                    velocity = 0;
                }
                UpdateMaxMin(velocity);
                datapointList[i] = new DataPoint(timeTable[i], velocity);

                p0 = new float[] { joint[JointType], joint[JointType + 1], joint[JointType + 2] };
            }
            UpdateView();
        }
Esempio n. 5
0
        /// <summary> 加速度 </summary>
        private void GetAccelerationList()
        {
            InitParameter();
            float[] p0 = new float[] { jointsList[0][JointType], jointsList[0][JointType + 1], jointsList[0][JointType + 2] };
            double  v0 = 0;

            datapointList[0] = new DataPoint(timeTable[0], 0);
            for (int i = 1; i < timeTable.Count; i++)
            {
                float[] joint = jointsList[i];
                int     t     = timeTable[i] - timeTable[i - 1];
                double  v     = Caliculater.GetVelocity(joint, JointType, p0, t);
                double  a     = (v - v0) / t;
                if (i < 3)
                {
                    a = 0;
                }
                UpdateMaxMin(a);
                datapointList[i] = new DataPoint(timeTable[i], a);
                p0 = new float[] { joint[JointType], joint[JointType + 1], joint[JointType + 2] };
                v0 = v;
            }
            UpdateView();
        }
Esempio n. 6
0
        private void CheckVelAndAngle(int pIndex, float[] joints, int jointType, int start, int mid, int end)
        {
            int tIndex = 0;

            if (pIndex == 1 || pIndex == 2)
            {
                tIndex = 1;
            }
            if (pIndex == 3 || pIndex == 4)
            {
                tIndex = 2;
            }

            long   t     = KinectManager.kinectTimer.ElapsedMilliseconds;
            double sumsq = 0;

            for (int i = 0; i < 3; i++)
            {
                sumsq += Math.Pow((joints[jointType + i] - p0[pIndex][i]) / (t - t0[pIndex]), 2);
            }
            double velocity = Math.Sqrt(sumsq);

            float[] vec1          = Caliculater.JointsToVecArray(joints, mid, start);
            float[] vec2          = Caliculater.JointsToVecArray(joints, mid, end);
            double  cos           = Caliculater.VecToCos(vec1, vec2);
            double  angle         = Math.Acos(cos);
            double  angleVelocity = (angle - angle0[pIndex]) / (t - t0[pIndex]);

            if (upValueIsUsed)
            {
                if (velocity - v0[pIndex] >= 0)
                {
                    upValue[pIndex] = true;
                }
                if (velocity - v0[pIndex] < 0)
                {
                    if (upValue[pIndex])
                    {
                        if (t - time[pIndex] > waitTime)
                        {
                            if (velocity < Vel[tIndex][0] && Vel[tIndex][1] < velocity)
                            {
                                if (angleVelocity < AngVel[tIndex][0] && AngVel[tIndex][1] < angleVelocity)
                                {
                                    Midi.OnNote(11, Chord.NoteList[Chord.NoteIndex][Mapping(joints[jointType + 1])], 240);
                                    time[pIndex] = t;
                                }
                            }
                        }
                    }
                    upValue[pIndex] = false;
                }
            }
            else
            {
                if (t - time[pIndex] > waitTime)
                {
                    if (Vel == null)
                    {
                        Console.WriteLine("null");
                    }
                    if (velocity < Vel[tIndex][0] && Vel[tIndex][1] < velocity)
                    {
                        if (angleVelocity < AngVel[tIndex][0] && AngVel[tIndex][1] < angleVelocity)
                        {
                            Midi.OnNote(11, Chord.NoteList[Chord.NoteIndex][Mapping(joints[jointType + 1])], 240);
                            time[pIndex] = t;
                        }
                    }
                }
            }

            p0[pIndex]     = new float[] { joints[jointType], joints[jointType + 1], joints[jointType + 2] };
            t0[pIndex]     = t;
            v0[pIndex]     = velocity;
            angle0[pIndex] = angle;
        }