Beispiel #1
0
 /// <summary>
 /// Simply calculates the velocity of a joint. Takes two versions.</summary>
 /// <param name="type">
 /// The JointType to get velocity from.</param>
 /// <param name="firstTime">
 /// First index of the persons cached skeletons</param>
 /// <param name="secondTime">
 /// Second index of the persons cached skeletons</param>
 /// <returns>
 /// Returns the absolute velocity in meters</returns>
 private double SimpleAbsoluteVelocity(JointType type, int firstTime, int secondTime)
 {
     if (!HasSkeleton(firstTime) || !HasSkeleton(secondTime))
     {
         throw new ArgumentException("No Skeleton at this Index");
     }
     return(SkeletonMath.DistanceBetweenPoints(person.GetLastSkeleton(firstTime).GetPosition(type), person.GetLastSkeleton(secondTime).GetPosition(type)) * 1000.0 / person.MillisBetweenFrames(1, 0));
 }
Beispiel #2
0
 private double GetDistance(JointType t1, JointType t2, int time)
 {
     if (!HasSkeleton(time))
     {
         throw new ArgumentException("No Skeleton at this Index");
     }
     return(SkeletonMath.DistanceBetweenPoints(person.GetLastSkeleton(time).GetPosition(t1), person.GetLastSkeleton(time).GetPosition(t2)));
 }
Beispiel #3
0
        /// <summary>
        /// Calculates the relative velocity of a joint referencing to a second one.</summary>
        /// <param name="steady">
        /// The referenctial JointType.</param>
        /// <param name="moving">
        /// The moving JointType of interest</param>
        /// <returns>
        /// Returns the relative velocity in meters</returns>
        public double GetRelativeVelocity(JointType steady, JointType moving)
        {
            if (!HasSkeleton(1))
            {
                return(0);
            }
            SkeletonPoint d0 = SubstractedPointsAt(steady, moving, 0);
            SkeletonPoint d1 = SubstractedPointsAt(steady, moving, 1);

            if (!HasSkeleton(3))
            {
                return(SkeletonMath.DistanceBetweenPoints(d0, d1) * 1000.0 / person.MillisBetweenFrames(1, 0));
            }
            SkeletonPoint d2 = SubstractedPointsAt(steady, moving, 2);
            SkeletonPoint d3 = SubstractedPointsAt(steady, moving, 3);

            return(SkeletonMath.Median(
                       SkeletonMath.DistanceBetweenPoints(d0, d1) * 1000.0 / person.MillisBetweenFrames(1, 0),
                       SkeletonMath.DistanceBetweenPoints(d1, d2) * 1000.0 / person.MillisBetweenFrames(2, 1),
                       SkeletonMath.DistanceBetweenPoints(d2, d3) * 1000.0 / person.MillisBetweenFrames(3, 2)
                       ));
        }