Skip to content

1Ghasthunter1/2020CarProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

2020 Car Project - Calculus AB

A script that finds the integral of data using trapezoids.

Optional: Open the Code Document

I Highly encourage you to view the code in your browser by clicking here: https://github.com/1Ghasthunter1/2020CarProject/blob/main/graphareafinder.py. If you look carefully, you will see all of the math terms, equations, and variables needed to solve this problem. I manunally coded all of these in myself, there was no copied code anyhwere here.

Car Project Code Theory

Math Theory

Although the original directions say to use squares, triangles, and quadrilaterals, I designed this program to operate exclusively with irregular quadrilaterals, so that any data input could be handled and processed.

Code Theory

The idea behind this code was to have a program that could read data off of an excel sheet, process the data, use the necessary geometric and trigonometric functions to find the area of each irregular quadrilateral, add up all of the areas of these shapes, and spit out the output.

This result that the program spits out is the area underneath the curve of data that was gathered in the car, and the unit for this data is equal to the units of the x axis (time in minutes), and the y axis (miles per hour). When you multiply the x axis units by 60, you arrive at time in hours. Miles / Hour * Hour yields the unit Miles, which is what this program outputs.

Explaining the code

Please note, when you see a "#SomeText And Words" In the code document, that is a comment, and I have left those there to help clear up what the program is doing at a certain time.

In essence, the program starts off by creating a set of pre-defined functions that will be used later. These functions include find_abcd, which simply finds the abcd values of a quadrilateral. There are also functions like find_s, find_area, etc. Note that all of these functions have been programmed myself and all of the math you see in these functions are all programmed by myself.

At the bottom of the program document, all of these functions are now used.

Events happen in this order:

  1. Get all of the data from excel(same as on the graph on my submitted assignment), and creates a list of all of the quadrilaterals the program has found.
  2. For each one of these quadrilaterals, the program first uses the "find_abcd" function, which simply takes the four vertices that we got from step 1 and uses distance formula to derive each of the side lengths, for a, b, c, and d, of each irregular quadrilateral.
  3. Then, the program uses the "find_s" function, which simply takes all four side length values (a, b, c, d), adds them together, and divides the result by two. Note that these formulas are all listed on my submitted document
  4. After, the program finds the theta value (also on submitted document). The function "find_theta" is relatively complex, and uses all of the points of the quadrilateral and all of the sides of the quadrilateral to find the theta. This function finds the cross-section across the irregular quadrilateral, and uses law of cosines to find each theta on the opposite sides of the quadrilateral.
  5. At this point, the program has the s value, the theta value, the a, b, c, and d value. All of this data is enough to use in our main equation (on turned in document), and the program plugs these variables into the function "find_area_of_quadrilateral", which returns the output.
  6. Finally, all of these areas are added together, and the program uses the "print" function to tell us that on the screen.

What the program shows me

Once I hit the run button, this is what the program shows:

From 0.0 to 2.0, The area is 0.0 Miles
From 2.0 to 4.0, The area is 0.5333 Miles  
From 4.0 to 6.0, The area is 1.1333 Miles  
From 6.0 to 8.0, The area is 0.85 Miles    
From 8.0 to 10.0, The area is 1.55 Miles   
From 10.0 to 12.0, The area is 2.6333 Miles
From 12.0 to 14.0, The area is 2.6333 Miles
From 14.0 to 16.0, The area is 2.6667 Miles
From 16.0 to 18.0, The area is 2.45 Miles  
From 18.0 to 20.0, The area is 2.2333 Miles
From 20.0 to 22.0, The area is 1.6 Miles   
From 22.0 to 24.0, The area is 0.9333 Miles
From 24.0 to 26.0, The area is 0.4833 Miles
The total area under the curve is 19.7 Miles

Each irregular quadrilateral has a range on the x-axis, within the two minutes specified for each recording interval. For each quadrilateral, the area is individually calculated. Then, all of the data is added together and printed out at the end of the program.

About

My code for the 2020 car project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages