ALGORITHMS FOR TENNIS RACKET ANALYSIS BASED ON MOTION DATA

Modern technologies, such as motion capture systems (both optical and markerless), are more and more frequently used for athlete performance analysis due to their great precision. Optical systems based on the retro-reflective markers allow for tracking motion of multiple objects of various types. These systems compute human kinetic and kinematic parameters based on biomechanical models. Tracking additional objects like a tennis racket is also a very important aspect for analysing the player’s technique and precision. The motion data gathered by motion capture systems may be used for analysing various aspects that may not be recognised by the human eye or a video camera. This paper presents algorithms for analysis of a tennis racket motion during two of the most important tennis strokes: forehand and backhand. An optical Vicon system was used for obtaining the motion data which was the input for the algorithms. They indicate: the velocity of a tennis racket’s head and the racket’s handle based on the trajectories of attached markers as well as the racket’s orientation. The algorithms were implemented and tested on the data obtained from a professional trainer who participated in the research and performed a series of ten strikes, separately for: 1) forehand without a ball, 2) backhand without a ball, 3) forehand with a ball and 4) backhand with a ball. The computed parameters are gathered in tables and visualised in a graph.


INTRODUCTION
Today the process of athlete training is supported by modern technologies.Simply recording the players' movements by a video camera may no longer be sufficient.Modern technologies can also be applied to tracking the movements of both the tennis player and the racket.They are expensive, but due to their accuracy they are more frequently used.Modern technologies are capable of monitoring many useful biomechanical parameters indicating the athlete's components of performance (e.g.angles, forces, ranges of motions, ground reaction forces).A motion capture system is an example of such technology.An optical system can record an athlete's movements in a specially designed laboratory (or a shaded room) because of special infra-red cameras placed on the walls or tripods that track the positions of markers attached to the human body, to a special suit or other objects (e.g. a tennis racket).Moreover, in modern motion capture systems the motion data may be combined with electromyography tests, providing synchronized information on muscle activity.However, the laboratory is not a natural environment for a player, so he or she may feel uncomfortable.The movements are limited to the walls.There is also a possibility of hitting and damaging the expensive cameras.To prevent such mishaps, a markerless motion capture system (e.g.Xsense) may be used while playing tennis on a court, which is an advantage.This kind of system computes the linear and angular motion usually based on readings from three gyroscopes and accelerometers installed in Inertial Measurement Units (IMUs).However, it is hard to track a tennis racket during such tests.This paper presents algorithms implemented in C++ designed for analysis of the tennis racket movement in two types of tennis strokes: forehand and backhand.These strokes are performed with and without a tennis ball.The recorded motion data is the source for the presented algorithms.The results obtained were used to compare these two types of strokes.The velocity of the tennis racket head and handle are analysed in both cases.The time at which the tennis racket reaches its greatest speed is indicated.The orientation of the racket is also analysed in both sagittal and axial planes.A professional trainer participated in the research and performed a series of ten strokes, separately for: 1) a forehand without a ball, 2) a backhand without a ball, 3) a forehand with a ball and 4) a backhand with a ball.
The racket movements (e.g. its velocity and orientation) while performing two most important tennis strokes provide information on the player's technique.The aim of the analysis is to verify the proposed algorithms in practice and to verify the selected parameters of forehand and backhand strokes with and without a ball.

RELATED RESEARCH
Motion may be captured using professional equipment, but also Kinect devices [5].Tracking the motion of the tennis racket together with the player's movements has been studied in many papers [2,3,4,9,12,13,14,15].Three aspects of the racket are analysed: its velocity, swing and orientation.Both motion capture systems (optical and markerless) and video cameras are used for the research.
The motion and pose in 3 dimensions were computed from a video recording [4].This method also allows for computing racket performance.The swing of the racket was investigated in [2].The speed of a tennis racket (as well as that of a golf club and a baseball bat) was analysed using 3-dimentional images obtained from two cameras.Reflective tape was placed on the elbow, around the wrist and around the racket's handle in two places.The maximum effort (both in standing and sitting positions) was calculated for each swing.The swing speed was approximately constant during the test.
Tracking a tennis racket using a markerless system (based on multiple cameras) and a visual hull is presented in [3].Views of a tennis racket were recorded and segmented into binary images.The racket's shape was obtained.The visual hull of the racket was created using the intersection of the volume of space formed by back-projecting the silhouettes from all input views.
In [11] the velocity of the tennis racket was calculated based on a monochrome recording made using a high-speed camera.
The Vicon system and a model consisting of sixty retro-reflective markers used to study the player's biomechanical parameters while serving on a full size court is presented in [14].Three 7-millimetre retro-reflective markers were attached to the tennis racket so that its velocity could be measured.An overall biomechanical analysis was performed.The orientation of the racket was expressed by its rotation.Twenty-two Vicon system cameras were used to study the kinematics of the player, racket and the tennis ball.Serving was divided into two groups: correct serves and service faults [12].The racket's velocity was estimated in [13].The timing of peak forward racket velocity, considered critical to accuracy in the first serve, was one of the results.The arm mechanics, racket kinematics, impact location and ball speed in the tennis serve were studied in [15].
The influence of three various rackets on the shoulder net joint movements of tennis players is presented in [1].Six cameras of the Eagle motion analysis system were used.The framerate was set at 256 fps.While serving, the racket and dominant upper limb kinematics were captured.Three spherical reflective markers were attached to the racket's head frame: two at the mid-height of both racket-face sides to determine the centre of the racket-face and one at the top of the handle.Moments, powers and rotations were calculated for each racket while serving.
The joint forces and torques were calculated using recordings from 12 Vicon system cameras with a frequency set at 300 Hz [6].The player had 38 retro-reflective markers attached to the body.Five markers were attached to the tennis racket.The hand and the racket were assumed to be one segment.The relationships between segmental angular momentum and ball velocity between the following events-ball toss, maximal elbow flexion, racket lowest point, maximal shoulder external rotation, and ball impact-were studied in [7].Also five markers were attached to the racket.
The tennis racket was not the only thing analysed using the motion capture system.In ad-dition, the moment of inertia, swing speed and velocity of the rod using 12 cameras of the Motion Analysis Corporation motion capture system were determined [9].Two markers were attached to the rod base and rod tips.The results indicate that there is a relationship between swing speed and moment of inertia.
In the research presented above in which an optical system was used, reflective markers were attached to the racket.The number varied from three to five.Very often reflective tape was placed on the racket's handle.All research focuses mainly on the biomechanical analysis of the body, while the racket is an additional factor.Most papers analysed the serve.
There is a lack of racket's movements analyses while performing tennis strokes, especially an analysis focusing on the forehand and backhand.There is a lack of implemented algorithms for determining the parameters needed for tennis racket motion analysis.The research presented in this paper concerns an analysis of a tennis racket which has seven retro-reflective markers attached.The markers define the overall shape of the racket.The research also includes a more precise analysis based on the described algorithms which are implemented in C++.Two basic strokes (forehand and backhand) are taken into consideration.The research is performed with a Babolat tennis racket.

METHOD
One left-handed 32 year-old tennis coach was the participant in this study.He was 192 cm tall and weighed 86 kg.He signed the ethical approval form for this research.
A passive optical motion capture system was used to track the participant and the racket while performing tennis strokes at the Laboratory of Motion Analysis and Interface Ergonomics at the Lublin University of Technology in Poland where interdisciplinary tests are performed [10].The research was conducted in a shaded room (without windows) so that no additional reflections appeared, which might have affected the quality of the data obtained.The motion capture system consisted of: eight NIR T40S cameras operating in near infrared, two reference video Bonita cameras, a Giganet hub collecting data, a desktop computer and a set of accessories (e.g.markers, a calibration wand, double-sided tape).
The system recorded the positions of the markers placed on the subject's body (each marker must be seen by at least two cameras).The reference video may be used both for data post-processing and for generating video files with a biomechanical model overlay.The equipment was supplied with Vicon's Nexus 2.0 software, used for system calibration, data recording and data processing.

Experimental procedure
The participant was prepared for the experiment according to the Plug-in Gait Model [8].39 retroreflective markers were attached to the participant using hypoallergenic double-sided tape as specified in the model.This model allows for calculating angles, torques and forces in a subject's joints.Each participant was measured for the purpose of creating and scaling a new subject in Nexus software.The measured dimensions are: height, weight, leg length, arm offset, knee, ankle, elbow and the thickness of both hands.The subject's calibration was performed as the next step in preparation.The participant stood in a "motorbike" pose which was captured.Apart from calibration, this procedure is important because it verifies the markers' visibility and placement.
The participant was told to perform two separate strokesstrikes, forehand and backhand, while running and avoiding a bollard placed on the floor.Because the participant was running, the strokes were more natural than hitting the ball from a standing pose.At first ten forehand strokes without a ball were performed, followed by ten backhand strokes without a ball.Next, these exercises were repeated with a ball.The participant hits a ball which is caught by a special net.

Tracking the racket
The racket was tracked during the research.Seven retro-reflective markers were attached to the racket according to the scheme presented in Figure 1.They allow one to reconstruct the shape of the racket.The markers were used for analysing the racket's movement.

Post-processing
Each 3D recording was post-processed using the Vicon Nexus software.The process consisted of four main steps: marker labelling, gap filling using interpolation methods, data cleaning (e.g.deleting all unlabelled markers) and applying the Plug-in-Gait model (only for human body).A new subject was created for the racket.It consisted of seven markers.The post-processed recordings were exported as C3D files.These files were used for further analysis.The files were processed by the authors' own piece of software created in C++ using the Biomechanical toolkit (b-tk) and Eigen libraries.

Algorithms
The first algorithm calculates the velocities in frames for the particular marker's coordinates.The time between two frames is the inverse of the markers frequency, set prior to the motion capture session.A Euclidean metric is used for computing the distance between the marker's positions in two consecutive frames.Then, the array of velocities is filled in with the computed values.The results are expressed in millimetres per second.A pseudo code of the above algorithm is presented in Figure 2.
The second algorithm calculates the inclination values of the angle of the vector defined by the two markers to reference plane in R3.The input parameters of the algorithm are the two specific markers and the names of the coordinates designating the plane (i.e.x and y, or x and z, or y and z).The angle values are determined in each frame of the recording.The results are placed in an array of size corresponding to the length of the analyzed recording.They show the change of the angle between the vector and its projection.The principle of the algorithm is: (1) to calculate the cross product of the 3D vector and its orthogonal projection, (2) to calculate the norm of the cross product (i.e. the value proportional to the sine of the angle between vectors) and (3) to compute the dot product (i.e. the value proportional to the cosine of the angle between vectors).The next step is to use the atan2 function, which produces an angle value within the range of [0, pi] (the range is limited because the norm is non-negative).In order to determine whether the vector is pointing above or beneath the plane, the following calculations are performed: (1) the difference between the input vector and its projection, (2) the sum of the coordinates of the difference is calculated.The sign of this sum is assumed to be the sign of the angle.A positive value indicates the vector's pointing above the plane, and a negative value -below the plane.A pseudo code of the above algorithm is presented in Figure 3.
The next algorithm determines the moments in time at which the value of the supplied angles (angles between vectors and their projection) equals zero.The inputs are the angles in consecutive frames.The adjacent two frames in which the angles have opposite signs are found.Then, the moment when the angle reaches zero is calculated using linear interpolation.The result is an array with the calculated moments within the entire recording.A pseudo code of the above algorithm is presented in Figure 4.
In Figure 4 an assumption is made that the interval between two consecutive frames is set to 0.01 second.It is due to fact that the system frequency was set to 100 Hz.

Post-processing
Each 3D recording was post-processed using the Vicon Nexus software.The process consisted of four main steps: marker labelling, gap filling using interpolation methods, data cleaning (e.g.deleting all unlabelled markers) and applying the Plug-in-Gait model (only for human body).A new subject was created for the racket.It consisted of seven markers.The post-processed recordings were exported as C3D files.These files were used for further analysis.The files were processed by the authors' own piece of software created in C++ using the Biomechanical toolkit (b-tk) and Eigen libraries.

Algorithms
The first algorithm calculates the velocities in frames for the particular marker's coordinates.The time between two frames is the inverse of the markers frequency, set prior to the motion capture session.A Euclidean metric is used for computing the distance between the marker's positions in two consecutive frames.Then, the array of velocities is filled in with the computed values.The results are expressed in millimetres per second.A pseudo code of the above algorithm is presented in Fig. 2. The second algorithm calculates the inclination values of the angle of the vector defined by the two markers to reference plane in R3.The input parameters of the algorithm are the two specific markers and the names of the coordinates designating the plane (i.e.x and y, or x and z, or y and z).The angle values are determined in each frame of the recording.The results are placed in an array of size corresponding to the length of the analyzed recording.They show the change of the angle between the vector and its projection.The principle of the algorithm

Racket's velocity
The velocity of a tennis racket's head was calculated using the RH1 marker while the rack-et's handle velocity was calculated using the RH7 marker (Fig. 1).These two markers coordinates were parameters of the function shown in Figure 2. The results for the forehand (FH) are presented in Table 1.The results for the backhand (BH) are gathered in Table 2.The racket's the sum of the coordinates of the difference is calculated.The sign of this sum is assumed to be the sign of the angle.A positive value indicates the vector's pointing above the plane, and a negative valuebelow the plane.A pseudo code of the above algorithm is presented in Fig. 3.The next algorithm determines the moments in time at which the value of the supplied angles (angles between vectors and their projection) equals zero.The inputs are the angles in consecutive frames.The adjacent two frames in which the angles have opposite signs are found.Then, the moment when the angle reaches zero is calculated using linear interpolation.The result is an array with the calculated moments within the entire recording.A pseudo code of the above algorithm is presented in Fig. 4. In Fig. 4 an assumption is made that the interval between two consecutive frames is set to 0.01 second.It is due to fact that the system frequency was set to 100 Hz.

Racket's velocity
The velocity of a tennis racket's head was calculated using the RH1 marker while the racket's handle velocity was calculated using the RH7 marker (Fig. 1).These two markers coordinates were parameters of the function shown in Fig. 2. The results for the forehand (FH) are presented in Table 1.The results for the backhand (BH) are gathered in Table 2.The racket's velocity for the strokes with (FH with ball and BH with ball) and without a ball (FH and BH) are compared.The algorithm presented in Fig. 2 computes the velocity in millimetres per The tennis racket's motion analysis contains the comparison of times for which the velocities of the racket's head and the racket's handle are the highest.The time differences for 40 strokes   (ten strokes for each of the analysed types) are presented in Table 3.
A graph representing a sample forehand stroke is depicted in Figure 5.The moment of impact is clearly visible.Just before the hitting the ball, the velocity of the racket's head (RH1) decreases slightly, so that the strike can be performed with precision.At the moment of impact, the velocity of the racket's handle (RH7) increases significantly.The wrist's movements (which can be identified by the handle's velocity) are correct.This dependency is confirmed by the results shown in Table 4.The moment of the racket's head maximum speed precedes the moment when the handle reaches its maximum speed.

Racket's orientation
The algorithm shown in Figure 3 was implemented for computing the angles: (1) between the racket and the floor's surface and (2) between the racket and the tennis net's surface, in the direction of the stroke.In tennis the racket's orientation relative to the net is a very important aspect.The racket's surface should be parallel to the net.At the moment of the impact two vectors are examined: 1) designated by the RH2 and RH5 markers (this vector indicates whether the racket is parallel to the net), and 2) designated by the RH6 and RH1 markers (this vector indicates the tilt angle of the racket relative the floor surface).In both cases the computeAnglesVectorAndProjection() and computeZeroAngleTime() are used.The angles of the racket's tilt in the tennis net plane are gathered in Table 4 together with the average velocity of the racket's head and handle at the moment of impact for all analysed strikes.
The results presented in Table 4 allow one to determine whether the racket's orientation during impact was correct or not.The computed angles indicate that the racket's head was slightly tilted towards the floor surface (the angle is negative).
The results for ten forehand strikes are presented in Table 5.They show the orientation of the axis of the rocket (RH6RH1 vector) relative to the floor surface, while the racket's head was parallel to the tennis net's surface (RH2RH5 angle between the vector and the net surface is equal to zero).
The negative values indicate that the racket's head was directed towards the floor.This is the correct orientation of the racket during impact.The occurrence of a parallel orientation of the racket to the net is also an evidence of proper stroke execution.

CONCLUSIONS
This paper presents algorithms for an analysis of tennis racket motion of the two most important strokes: the forehand and the backhand.The tennis strokes were recorded using Vicon motion capture system consisting of eight NIR cameras.Seven retro-reflective markers were attached to the tennis racket for the purpose of this analysis.The results were generated by a piece of custom software created for the purpose of this research.The C3D file consisting of the motion data was the input data to the program.The presented algorithms for computing a marker's velocity and the racket's angles in two surfaces were implemented in the software.They analyse the files and compute the necessary values.
The algorithm from Figure 3 is useful for the assessment of the stroke technique and determining whether, during its execution, the plane of the racket's head is parallel to the plane of the tennis net.Another element of this analysis is to calculate the speed of the racket during the stroke using algorithm from Figure 2. Using the algorithm in Figure 3, points in time are found in which the angle between the racket head and the reference plane is zero.At these points in time the speed of the racket's head and its handle is calculated.Modern 3D technology is very helpful in training tennis players.A motion capture system can be used for analysis of the captured athletes' data.The system allows for the recording of a tennis player's motion and his tennis racket's movement.This article presents the parameters of the tennis racket's motion calculated for the forehand and backhand strokes using the described algorithms.The strokes were performed with and without a ball.The velocity of the selected elements of the tennis racket's head and handle was calculated.The orientation of the racket was also analysed during impact.Angles between (1) the racket and the floor surface and (2) the racket and the tennis net's surface were calculated.The orientation of the racket is a crucial element of correct tennis stroke execution.From the presented analysis it is also possible to estimate the movement repeatability for a particular tennis player.
A comparison of the motion capture data and the presented algorithms is very useful for analysing a player's technique while performing strokes.The motion capture system is very precise, which results in the precision of the generated results.Although, the results are not computed while performing the exercises (post-processing is needed), they may provide valuable knowledge for the player and the trainer.

Fig. 5 .
Fig. 5.The velocity of the tennis racket's head and handle

Table 3 .
The time differences for maximum velocities of racket's head and racket's handle

Table 4 .
The tilt angle between the tennis racket and the net surface with the velocity of the racket's head and handleMovement Angle RH6RH1 Mean(±SD) [°] Head velocity Mean(±SD) [km/h] FH7 velocity Mean(±SD) [km/h]

Table 5 .
The tilt angle between the tennis racket and the net surface with the velocity of the racket's head and handle for ten forehand strokes