Nature of Code Final

For my project, I wanted to create a simulation to see if a home run hit in one major league ballpark would leave another ballpark. At the beginning, my expectations were really lofty in terms of what factors I wanted to take into account. And by so lofty I meant: all of them. I wanted to take into account, humidity, air resistance, wind, exit velocity, distance travelled, etc. After attempting to do this, I figured it would be best if I started a bit simpler by taking weather out of it.

I started by extracting only baseball factors such as distance, exit velocity and launch angle. I used ESPN’s hit tracker – which keeps track of every single home run each season – as a reference for all of this information. I then created some code where I could begin applying forces to things. Due to how many factors needed to be taken into account plus the fact that pixels don’t really measure distance, there were certain constants that I needed to take into account. For example, gravity was always set to 0.2 and acceleration was always set to 5. As I begin to advance this project and bring in different factors, these things will change but keeping those two forces constant’s allowed me to advance my project.

I’ll get more into how I created the code below, but for now let’s take a look at the code in action.

This was the longest home run that was hit in 2016 and it was a good place to start. I knew that if I could map this, I would have the highest threshold for homeruns considering none travelled further than this. It was this home run that let me test if my code was working and in the end, it ended up being successful as you can see below. 

Now all I needed to do was test to see if a home run hit in one park would work in a different park. 

This is Manny Machado’s grand slam that he hit on April 28th. If we look at the code first we get the sense that it barely left the yard. Let’s take a look to see if that’s true. 

It is! Now let’s take a look to see if that same hit would’ve left the yard in Comerica Park. 

It wouldn’t have. The sketch works!

Let’s dive a bit deeper though. What can we tell about the data before we see the home run. 

If we look at Alex Gordon’s Home Run in the sketch, we get the feeling that it too barely left the park in CF. 

I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Once again, the video shows this to be true.

How about a home run that wasn’t hit to center field? Can we use to sketch to see if it wasn’t hit to right or left field but hit to center instead, it still would’ve been a home run?

Let’s take a look at Chris Davis’ home run against the Blue Jays. It left the yard in right field and just barely made it over. 

So if that same hit was directed towards center field, would it have been a home run?

Nope, it looks like it would’ve come up just short. 

Leave a Reply

Your email address will not be published. Required fields are marked *