32
Acoustical Motion Perception Trainer Rick Drayton Michael Galas Anthony Tancredi Project Advisor: Dr. Mark Jupina Villanova University ECE 3971 April 30, 2013

AMPT Final Proposal

  • Upload
    frank

  • View
    24

  • Download
    2

Embed Size (px)

DESCRIPTION

h

Citation preview

Page 1: AMPT Final Proposal

Acoustical Motion Perception Trainer

Rick DraytonMichael Galas

Anthony Tancredi

Project Advisor: Dr. Mark Jupina

Villanova UniversityECE 3971

April 30, 2013

Page 2: AMPT Final Proposal

Table of ContentsPage

1. ABSTRACT ……………………………………………………………………………..1

2. BACKGROUND AND STATE-OF-THE-ART: “WHAT + WHY?” ……………..22.1 Overview: Problem, Opportunity, Need Goals & Objectives ……..22.2 Prior Work: Relation to Contemporary Issues ……………………..22.3 Potential Impact: Global & Societal Context ……………………..32.4 Ethical Issues ……………………………………………………………..32.5 Organization of the Proposal ……………………………………………..4

3. SPECIFICATIONS: “WHAT THE SYSTEM WILL DO” ……………………..53.1 Functional Specifications ……………………………………………..53.2 Performance Specifications ……………………………………………..53.3 Environmental Specifications ……………………………………………..5

4. DESIGN OVERVIEW: “HOW?” ……………………………………………………..64.1 Tasks ……………………………………………………………………..6

4.1.1 Audio ……………………………………………………………..64.1.2 Video ……………………………………………………………..64.1.3 Real-Time ……………………………………………………..7

4.2 Proposed Design Approach ..……………………………………………74.3 Block Diagrams of System Structure ……………………………………..8

5. PROJECT MANAGEMENT ……………………………………………………155.1 Schedule and Milestones ……………………………………………155.2 Personnel ……………………………………………………………155.3 Key Parts & Components ……………………………………………165.4 Skills and Tools ……………………………………………………165.5 Budget ……………………………………………………………17

6. CONCLUSIONS ……………………………………………………………………18

REFERENCES ……………………………………………………………………………19

APPENDIX A: COMPLEMENTARY MATLAB CODE FOR FIGURE 2 ……………20

Page 3: AMPT Final Proposal

1. ABSTRACT

This document outlines and provides the full details of the Acoustical Motion Perception Trainer (AMPT) project. Naturally, individuals have the ability to lock their eyes onto an object in motion, known as smooth pursuit. It varies amongst individuals and correlates strongly to a specific type of motion perception ability, known as high-level motion perception [1]. The AMPT will serve as an auditory training system for baseball players. The AMPT will attempt to help a batter hear the ball better as it is released from the pitcher and approaches home plate. The implementation of this system will rely heavily on Matlab and the various tools within that environment. Captured video of the pitch will be streamed into Matlab and audio will be generated and delivered to the batter. All of this will take place in real-time.

The first section will discuss some state-of-the-art work that will include topics such as prior research, potential impacts, and ethical concerns that relate to the development of the AMPT. The following section will guide readers through the specifications of the system, such as functionality, performance, and environmental expectations. Finally, the proposal will come to a close with details regarding the project management such as the responsibilities of each group member and also a detailed budget report.

1

Page 4: AMPT Final Proposal

2. BACKGROUND AND STATE-OF-THE-ART: “WHAT + WHY?”

2.1 Overview: Problem, Opportunity, Need Goals & Objectives

In a prior study [2], it has been found that there is a direct connection in the brain between the visual cortex and the auditory sense in blind people. Taking this conclusion one step forward, can the motion perception of a sighted person be enhanced through the conditioning of their auditory senses? For example, can auditory training assist a baseball player in visually tracking the trajectory of a pitch based on the “sound” of the pitch? Before testing this hypothesis, the goal is to build a system that can track the motion of an object, such as a baseball, while generating tones representative of the object’s path and velocity. The culmination of this senior project will show how certain skills are used that have been provided through various Villanova University ECE courses. These skills include, but are not limited to, coding in Matlab and designing, testing, and debugging a system.

2.2 Prior Work: Relation to Contemporary Issues

The main hypothesis of this project is based on the previous research done at the Hebrew University of Jerusalem, which concluded that certain regions of the visual cortex of the brain of a blind person were excited by the auditory input from a sonar vision system [2]. This suggests that the visual cortex can examine shapes through this sonar vision system.

Prior sports science applications relevant to the proposed project are the Pitchf/x system and the SmartKage. Pitchf/x is a two-camera baseball tracking system which is currently used in MLB (Major League Baseball) ball parks [3]. This system tracks the trajectory of the baseball, and records physical attributes of the pitch such as the position, velocity, and acceleration in all three dimensions. The SmartKage, which is simply an electronic batting cage, uses biometrics in order to measure the athletic performance of a batter. These systems use biometrics, which is defined as the sport science that applies the laws of mechanics, in order to measure performance in athletic events, such as the projection of a pitch or the forces applied to a batted baseball. Potentially, the AMPT system could play a complementary role to the existing Pitchf/x and SmartKage systems.

2

Page 5: AMPT Final Proposal

2.3 Potential Impact: Global & Societal Context

A wide range of possibilities can arise from the successful implementation of an Acoustical Motion Perception Trainer (AMPT). One of the immediate and obvious effects would be an improvement in the game of baseball. If a player is able to use this system and cultivate enhanced senses, then their overall gameplay would improve, thus leading to an increase in competition. Other players will seek to use this system and reap its benefits.

Another impact of such a system would be its use in other sports such as basketball or tennis. Basketball players can ideally apply this system in free throw shooting while tennis players can better predict the possible path of a tennis ball during a serve.

If all else fails, there is a strong possibility of a carnival game similar to that of the pitching radar implemented in ball parks. A young baseball fan can throw a pitch and the system will generate the audio tones based on the baseball’s path. The thrower will then be able to see and hear their pitch, and then be able to compare it to the sound and motion of different pitches thrown by MLB pitchers. (Cole Hamels, R.A. Dickey, Justin Verlander)

2.4 Ethical Issues

As with any research, ethical issues are a huge concern that must be looked into before research begins. It is important to note, that the conclusions of the given project is not outweighed by its ethical failures. The AMPT Project does have a couple questionable ethical concerns that must be looked into. The first regards the idea of limited access. The system currently being proposed will be moderately expensive to implement. Because not everyone in the same level of competition may be in the same economic bracket, some athletes may have a better opportunity than others to access this system. Because of this, those athletes will have a competitive advantage over the ones who don’t have access. A possible solution to this problem is to only make the system accessible to MLB organizations and their affiliates.

Even more crucial than the previous ethical issue is that of health. Just as with any study of one’s body, health issues must be addressed when performing research of this project. Negative side effects have many a times been only recognized after something comes out to the public, such as the radiation that is emitted from electronic devices. If this system becomes public, the user’s auditory senses will be trained in order to help another sense. In order to better predict the effectiveness of the AMPT, it would be wise to consult with a neurologist or sports psychologist. Analysis from a neurologist or sports psychologist would be very helpful in addressing these ethical concerns. Although it doesn’t seem particularly harmful, it is important to realize this notion is not of 100 percent.

3

Page 6: AMPT Final Proposal

2.5 Organization of the Proposal

The following sections will first discuss the specifications that were developed and then transition into the framework for the project management. This will provide the reader with details on how the work load will be divided equally between each team member while trying to utilize the individual skills that each member possesses. The specifications section will hold all the information on how the system is to behave from a functional, performance, and environmental stand point. In between the transition to talk about project management, there will be a design overview section that provides images and details on how the system will look. Included in the project management section will be a tentative schedule to be followed in order to stay on pace with the completion of the project. The final details that will be covered are the budget and expenses that will be very important factors when determining how well the ideas will be implemented.

4

Page 7: AMPT Final Proposal

3. SPECIFICATIONS

3.1 Functional Specifications

The main functions that the system will perform are as follows:- Stream live video of ball being thrown into Simulink- Extract the ball’s path in Simulink in real-time- Generate auditory feedback in Simulink in real-time- Produce unique audio signatures based on type of pitch

Other functions include:- A robust, compiled Matlab code- Reliable way for batter to hear the audio- Ability to function in real-time- Backwards compatibility with Pitchf/x

3.2 Performance Specifications

The functions of the AMPT system will perform under the following conditions:- Very low latency meaning < 10 milliseconds- Ability to differentiate between 2 main types of pitches (fastball and non-

fastball)- Recognition of varying pitch speeds from 50 – 100 mph- Durability in ideal baseball game conditions (32 < T < 100 degrees F)- Durability in various wind speeds from 0 – 25 mph

3.3 Environmental Specifications

One of the qualities of a perfect system is its ability to perform in various conditions. One that is always a concern is how it performs under environmental conditions. The system will be under a controlled environment. The main area of the implementation of the AMPT will be an indoor batting cage. This is the exact environment in which SmartKage works. This environment alleviates any concerns about unpredictable external conditions such as extreme temperatures and wind speeds. With this in mind, it will be easier to focus on the core requirements.

5

Page 8: AMPT Final Proposal

4. DESIGN OVERVIEW: “HOW?”

4.1 Tasks

4.1.1 Audio

The final output of the real-time system that will be implemented is an audio signal. The main idea is that a pitch can be distinguished through an audio signature that will be projected. For example, a curve ball will have a different audio signature than a fastball, so the batter will be able to recognize which pitch is approaching him. The signal will either be projected through speakers around the batter, or it will be hardwired into the batter’s helmet. The audio signal is produced from the trajectory of the ball, which includes its speed, movement, and acceleration in the x, y, and z directions. Using the equations of motion and Simulink, the necessary visual inputs are provided to create the audio signals wanted for this design. Using special tools provided by Matlab such as the RealTimeAudioProcessor, it is then possible to project the audio signature based on the Simulink results in real time [4].

4.1.2 Video

The main objective for the video task is to utilize the image acquisition toolbox within Matlab in order to stream live video. This will require some research on what type of video files are compatible with the image acquisition toolbox. From that research it will be easier to determine what type of camera is the best fit for this project. The two most important factors that will involve choosing the right camera is how efficient it is at streaming live video into Matlab and how expensive each camera would be seeing as two of them are needed.

Also worth noting is that Pitchf/x uses cameras with a 60 frames/second capability. Matlab’s default frame rate is 30 frames/second so research must be done in order to figure out how to implement the camera’s video capabilities of an ideal 60 frames/second. Furthermore, research must be done in the field of USB technology in order to determine what will provide for the fastest data transfer. This will most likely involve using a USB 3 port and its capabilities. Using this will enable the implementation of higher frame rates because of the data transfer speeds.

6

Page 9: AMPT Final Proposal

4.1.3 Real-Time

This task is probably the most important task as it involves bringing together the two tasks above by making each of them real-time components of the project. The audio signal will have to be generated as the video is being fed into Matlab. This audio signal will then have to be outputted to a sound system as the baseball travels towards home plate. This can only be made possible with an already compiled Matlab code. Furthermore, this task will require much debugging, because one of the main goals is to have a system with the lowest possible latency. Many attempts will be made to reduce the latency until a satisfactory time is met.

4.2 Proposed Design Approach

The proposed tentative design for the implementation of the AMPT in a batting cage can be seen in Figure 1. The cameras are designated the letter “A” while speakers are “B”. A pitcher and batter will be positioned in their regular areas that they would normally be in. For safety purposes pitchers always have an L-screen in front of them that will protect them from getting hit by the ball if the batter hits it up the middle. One camera will be behind the pitcher and will focus on the ball as it is released from the pitcher’s hand while a second camera will be to the batter’s left (batter’s right if right-handed) and will focus on the ball as it approaches the batter. The speakers will essentially surround the batter as seen below. This allows for the batter to hear the amplified audio of the pitch as it nears the home plate. An alternative idea for the speakers is to have a speaker located on the inside of the batting helmet to allow for better hearing of the audio.

7

Page 10: AMPT Final Proposal

Figure 1: Batting Cage Shown With Ideal Positions of Cameras and Speakers

4.3 Block Diagrams of System Structure

The following Figure 2 details the type of block diagram that will be used in the design and construction of this project. This diagram involves the application of the baseball equations of motion that are similarly used in Pitchf/x. Figures 3 – 11 show the plots of the position, velocity, and acceleration of the baseball in the x, y, and z directions. The coefficients of each variable will determine the shape of the plots. By using data that is obtained in a similar fashion like Pitchf/x, these coefficients can be determined [5]. The complementary Matlab .m file includes the baseball equations of motion and can be seen in Appendix A.

8

Page 11: AMPT Final Proposal

Figure 2: Simulink-Block Diagram of the Baseball Equations of Motion

9

Page 12: AMPT Final Proposal

X Direction:

Figure 3: X-Position (ft) vs. Time (s)

Figure 4: X-Velocity (ft/s) vs. Time (s)

10

Page 13: AMPT Final Proposal

Figure 5: X-Acceleration (ft/s2) vs. Time (s)

Y Direction:

Figure 6: Y-Position (ft) vs. Time (s)

11

Page 14: AMPT Final Proposal

Figure 7: Y-Velocity (mph) vs. Time (s)

Figure 8: Y-Acceleration (m/h^2) vs. Time (s)

12

Page 15: AMPT Final Proposal

Z Direction:

Figure 9: Z-Position (ft) vs. Time (s)

Figure 10: Z-Velocity (ft/s) vs. Time (s)

13

Page 16: AMPT Final Proposal

Figure 11: Z-Acceleration (ft/s2) vs. Time (s)

14

Page 17: AMPT Final Proposal

5. PROJECT MANAGEMENT

5.1 Schedule and Milestones

Figure 12: Gantt Chart Showing Schedule of Project Tasks

5.2 Personnel

Rick Drayton Michael Galas Anthony Tancredi

Job/Task

Video aspect of project, research compatible video formats, find way to read video into Matlab

Robust method to implement data in real-time (Computer Vision), figure out ways cameras can be set up

Generate real-time (low-latency) audio signal (tones) based on projectile motion extracted from real-time video.

Figure 13: Table Showing the Tasks and Responsibilities of Each Member

15

Page 18: AMPT Final Proposal

Personnel Rationale:

It is fitting for Mr. Drayton to handle the video aspect of the project since he has the most experience in that field. He is very knowledgeable and can determine the best compatibilities between the video cameras and Matlab (i.e. ideal frame rate and video file)

Mr. Galas will handle the real-time aspect because he is a problem solver. He can take a problem and come up with solution(s) that will address the system’s needs. This will serve a key role in determining the best position for the cameras and the implementation of the system performing in real-time.

Mr. Tancredi will handle the audio aspect because he has a lot of experience with Matlab. This will be very important because the bulk of the coding is for the audio aspect and will be done on this interface.

5.3 Key Parts & Components

- laptops- Matlab with Simulink Toolbox - USB 3 - 30/60 fps Cameras- Test Area - Baseball Volunteers - Baseball Equipment - Sound System

5.4 Skills and Tools

Many skills will be needed in order for the AMPT to be successful. The most important skill is knowledge of programming in Matlab. This is the programming environment for which the coding will be generated, compiled, and run. Because of the necessity of Matlab, it is very vital that all the updated packages are installed. This will allow for full functionality and provide much ease in the coding process. This requires the need for Simulink, which is available through Matlab [6]. Simulink will be very important because without it the video streaming and audio generation will not be possible to achieve. Lastly, other tools that are accessible in Simulink are Image Acquisition, RealTimeAudioProcessor and Computer Vision. Image Acquisition will be capable of streaming the video while Computer Vision will allow for the extraction of the ball’s path.

16

Page 19: AMPT Final Proposal

5.5 Budget

Product Estimated CostCameras $350Baseball Equipment $100Transportation $100Student Labor (All Three Students) $3500

Figure 14: Tabulated Budget

17

Page 20: AMPT Final Proposal

6. CONCLUSIONS

This project will be a very interesting and brain stimulating design process while seeking to make scientific breakthroughs in the world of athletics. It is apparent that the current task will be difficult, as the Matlab tools are far beyond the normal tasks that are required in previous courses mandatory of the computer engineering curriculum. However, it is very possible that the basic skills acquired throughout these few years of college will provide a solid background to perform these tasks. Being able to work on a project like this is also a plus because each team member has a great interest in sports. This motivation will lead to even harder work opposed to a project that doesn’t fit the interests of each team member. Furthermore, this will be an amazing experience, as an opportunity is given to change the training world of sports while learning new material as well as attaining knowledge in software development.

18

Page 21: AMPT Final Proposal

REFERENCES

[1] Wilmer, Jeremy B. and Nakayama, Ken, Two Distinct Visual Motion Mechanisms for Smooth Pursuit: Evidence from Individual Differences, Neuron 54, pp. 987-1000, 2007.

[2] Striem-Amit, Ella et al., Reading with Sounds: Sensory Substitution Selectively Activates the Visual Word Form in the Blind, Neuron 76, pp. 640-652, 2012.

[3] Fast, Mike, What the Heck is PITCHf/x?, The Hardball Times Baseball Annual 2010, pp. 1-

6, 2010.

[4] http://www.mathworks.com/matlabcentral/fileexchange/37770-real-time-audio-processor

[5] http://www.brooksbaseball.net/

[6] Leghmizi Said and Boumediene Latifa (2011). Modeling and Control of Mechanical Systems

in Simulink of Matlab, Applications of MATLAB in Science and Engineering, Prof. Tadeusz

Michalowski (Ed.), ISBN: 978-953-307-708-6, InTech, Available from:

http://www.intechopen.com/books/applications-of-matlab-in-science-andengineering/

modeling-and-control-of-mechanical-systems-in-simulink-of-matlab

19

Page 22: AMPT Final Proposal

APPENDIX A: COMPLEMENTARY MATLAB CODE FOR FIGURE 2

% bball_eqs_of_motion_constants.m

%

% Set precision - default is DIGITS = 10

DIGITS = 20;

% Set display format

format short;

%

% Enter or import the 9 parameters from the pitchfx data base

%

x0_ft = -2.509 % x0_ft - initial x position in feet at y0 (+x direction is to the right of catcher)

x0 = 0.3048*x0_ft % x0 - initial x position in meters at y0

y0_ft = 50 % y0_ft - initial y position in feet away from the back tip of home plate (+y direction is

toward the pitcher)

y0 = 0.3048*y0_ft % y0 - initial y position in meters away from the back tip of home plate

z0_ft = 5.928 % z0_ft - initial z position in feet up from the ground at y0 (+z direction is up)

z0 = 0.3048*z0_ft % z0 - initial z position in meters up from the ground at y0 (+z direction is up)

vx0_ft = 9.182 % vx0_ft - initial x direction velocity in ft/s at y0

vx0 = 0.3048*vx0_ft % vx0 - initial x direction velocity in m/s at y0

vy0_ft = -132.785 % vy0_ft - initial y direction velocity in ft/s at y0

vy0 = 0.3048*vy0_ft % vy0 - initial y direction velocity in m/s at y0

vz0_ft = -10.967 % vz0_ft - initial z direction velocity in ft/s at y0

vz0 = 0.3048*vz0_ft % vz0 - initial z direction velocity in m/s at y0

ax_ft = -19.268 % ax_ft - x direction acceleration in ft/s2 at y0 (assumed constant throughout

trajectory)

ax = 0.3048*ax_ft % ax - x direction acceleration in m/s2 at y0 (assumed constant throughout

trajectory)

ay_ft = 30.712 % ay_ft - y direction acceleration in ft/s2 at y0 (assumed constant throughout

trajectory)

ay = 0.3048*ay_ft % ay - y direction acceleration in m/s2 at y0 (assumed constant throughout

trajectory)

az_ft = -16.580 % az_ft - z direction acceleration in ft/s2 at y0 (assumed constant throughout

trajectory)

az = 0.3048*az_ft % az - z direction acceleration in m/s2 at y0 (assumed constant throughout

trajectory)

%

%

% Properties of a Baseball

m = 0.145 % mass given in kg, the mass in ounces is 5.125 oz.

circum = 0.231775 % circumference given in meters, the circumference in inches is 9.125 in.

R = 0.03683 % radius given in meters, the radius in inches is 1.45 in.

20

Page 23: AMPT Final Proposal

R_in = 1.45 % radius given in inches

A = 0.00426 % cross-sectional area in meters squared

%

% Properties of Air

rho = 1.146 % air density in kg/m3

%

% Normalization factor used in the equations of motion which takes into account the effect of air density on the

cross-section of the ball and

% takes into account the effect of the ball's mass

K = 0.5*rho*A/m % a numerical factor in units of 1/m used in equations of motion

K_ft = 0.3048*K % a numerical factor in units of 1/ft used in equations of motion

% K_ft = 5.153e-3 % K - a numerical factor, K = 5.44e-3 1/ft = 0.017847769 1/m

% K = K_ft/0.3048 % K - a numerical factor in units of 1/m

%

%

% The pitched ball travels in the negative y-direction. The catcher faces the positive y-direction. The positive z-

direction

% points upward. The positive x-direction is towards the catcher's right or the pitcher's left.

% The batter's box for a right-handed (RH)hitter lies on the -x axis.

% The batter's box for a left-handed (LH)hitter lies on the +x axis.

%

% In these expressions, the projection of the spin or angular velocity vector (omega) in the x-z plane makes an

angle phi with the x axis.

% The spin vector makes an angle psi with the y-axis. For psi = 90 degrees, the spin vector lies in the x-z plane

and

% and since vy is negative, the Magnus force makes an angle theta = phi - 90 with the x axis.

% The Magnus Force vector is always perpendicular to the spin vector (cross product of the vectors omega and v,

omega X v ).

%

% Therefore, for the following 4 cases assuming that psi=90 (angles in degrees):

% 1. phi = 0 (top spin, curve ball) so omega lies in +x direction and

% theta = -90 or 270 so Magnus Force lies in the -z direction (downward acceleration, enhances the effects of

gravity)

% 2. phi = 90 (side spin, right-hander's slider) so omega lies in +z direction and

% theta = 0 so Magnus Force lies in the +x direction (acceleration away from RH hitter and into a LH hitter)

% 3. phi = 180 (back spin, fast ball) so omega lies in -x direction and

% theta = 90 so Magnus Force lies in the +z direction (upward acceleration, decreases the effects of gravity)

% 4. phi = 270 or -90 (side spin, left-hander's slider) so omega lies in -z direction and

% theta = 180 so Magnus Force lies in the -x direction (acceleration away from LH hitter and into a RH hitter)

%

%

g = 9.80665 % g - acceleration due to gravity (32.174 ft/s2 or 9.80665 m/s2)

% Velocity values

vyf_ft = -sqrt(vy0_ft^2 - 2*ay_ft*(y0_ft - 1.417)) % Final velocity in the y direction at the front edge of home

plate (yf = 1.417 feet)

21

Page 24: AMPT Final Proposal

time = (vyf_ft - vy0_ft)/ay_ft % Total travel time between y0 and yf

vxav_ft = (2*vx0_ft + ax_ft*time)/2 % Average velocity in the x direction in ft/s

vyav_ft = (2*vy0_ft + ay_ft*time)/2 % Average velocity in the y direction in ft/s

vzav_ft = (2*vz0_ft + az_ft*time)/2 % Average velocity in the z direction in ft/s

vav_ft = sqrt(vxav_ft^2 + vyav_ft^2 + vzav_ft^2) % Magnitude of Average velocity in ft/s

vav_mph = vav_ft/1.467 % Magnitude of Average velocity in mph

vav = 0.3048*vav_ft % Magnitude of Average velocity in m/s

%

% Acceleration Values and Coefficients

%

% Effect of Drag

adrag_ft = -(ax_ft*vxav_ft + ay_ft*vyav_ft + (az_ft + 32.174)*vzav_ft)/vav_ft % Drag Acceleration in ft/s2

Cd = adrag_ft/(K_ft*vav_ft^2) % Drag Coefficient (unitless)

%

% Magnus Force Components due to spin (Lift)

axmag_ft = ax_ft + adrag_ft*vxav_ft/vav_ft % Magnus Force Acceleration in x direction in ft/s2

aymag_ft = ay_ft + adrag_ft*vyav_ft/vav_ft % Magnus Force Acceleration in y direction in ft/s2

azmag_ft = az_ft + adrag_ft*vzav_ft/vav_ft + 32.174 % Magnus Force Acceleration in z direction in ft/s2

amag_ft = sqrt(axmag_ft^2 + aymag_ft^2 + azmag_ft^2) % Magnitude of Acceleration in ft/s2

Cl = amag_ft/(K_ft*vav_ft^2) % Lift Coefficient (unitless)

%

% Direction Cosines of Spin

wx = (vyav_ft*azmag_ft - vzav_ft*aymag_ft)/(vav_ft*amag_ft) % Direction Cosines in x direction

wy = (vzav_ft*axmag_ft - vxav_ft*azmag_ft)/(vav_ft*amag_ft) % Direction Cosines in y direction

wz = (vxav_ft*aymag_ft - vyav_ft*axmag_ft)/(vav_ft*amag_ft) % Direction Cosines in x direction

%

% Calculate the angle between the Magnus Force vector and the x axis

% (ccw rotation is positive from the batter's or catcher's perspective)

if azmag_ft > 0

theta = 180*atan2(azmag_ft,axmag_ft)/pi

else

theta = 360 + 180*atan2(azmag_ft,axmag_ft)/pi

end

%

% Calculate the angle between the spin vector projection in the x-z plane wrt the x axis

% phi = theta + 90

% (ccw rotation is positive from the batter's or catcher's perspective)

if wz > 0

phi = 180*atan2(wz,wx)/pi

else

phi = 360 + 180*atan2(wz,wx)/pi

end

%

% Calculate the angle of the spin vector wrt the y-axis

psi = 90 - 180*asin(wy)/pi

22

Page 25: AMPT Final Proposal

%

% Spin parameter based on CL using the best experimental fit available

S = 0.4*Cl/(1-2.32*Cl)

%

% Angular velocity magnitude estimate based on the Magnus Force

omega_rpm = S*(60*vav_ft)/(2*pi*R_in/12) % angular velocity given in revolutions per minute

omega = S*vav/R % The SI unit of angular velocity is radians per second

%

% Movement in units of inches in the x and z directions

pfx_x = 0.5*12*axmag_ft*time^2

pfx_z = 0.5*12*azmag_ft*time^2

%

% Convert angles from degrees to radians

phi = phi*pi/180;

psi = psi*pi/180;

theta = theta*pi/180;

% C - coefficients for the three equations of motion stored in a 3 x 3 matrix

C = [-K*Cd, -K*Cl*sin(phi)*sin(psi), K*Cl*cos(psi); K*Cl*sin(phi), -K*Cd, -K*Cl*cos(phi); -K*Cl*cos(psi),

K*Cl*cos(phi)*sin(psi), -K*Cd]

23