Package: cfmdarts
cfmdartscfmdarts is a Python library that simulates the projectile motion of darts.Table of ContentsIntroductionInstallationTutorialsHow To GuidesTestingExplanationLicenseIntroductionThis project has an extremely trivial goal. Simply input 3 values relating to the throw of a darttilt angleswivel angle (both in degrees)initial velocity (in metres per second).Then output the score of which is obtained. This project involves many areas of mathematics to solve.
Primarily Mechanics and Geometry.InstallationUse the package managerpipto installcfmdarts.pipinstallcfmdartsNOTE: It is recommended to have a Python version which is greater that 3.6 to be installed.TutorialIn order to use cfmdarts is really simple. To use in your project, you typefromcfmdartsimport*How To GuidesThese next guides are simple pieces of code to get you started using cfmdarts.Creating a new Projectile object.fromcfmdartsimport*#Creating a new Projectile object called Object1#with tilt_angle=2, swivel_angle=1.5 and initial_velocity=21Object1=cfmdarts.Projectile(2,1.5,21)Outputting a new Projectile objects range, height and shift values.fromcfmdartsimport*#Creating a new Projectile object called Object1#with tilt_angle=2, swivel_angle=1.5 and initial_velocity=21Object1=cfmdarts.Projectile(2,1.5,21)##This outputs the followprint(Object1.range())print(Object1.height())print(Object1.shift())Output:2.3708124182033570.020197835523596720.06206063411897303Creating a coordinates object to calculate and output the cartesian and polar coordinatesfromcfmdartsimport*#Creating a coordinates object called coord1#with tilt_angle=2, swivel_angle=1.5 and initial_velocity=21Coord1=cfmdarts.Coordinates(2,1.5,21)## These two statements below print out the## cartesian and polar coordinates.print(Coord1.cartesian_coordinates())print(Coord1.polar_coordinates())Output:[0.06206063411897303,0.02019783552359672][0.06526465250874554,18.027647207949578]Creating a data simulation using the dart_simulation that returns a final score.fromcfmdartsimport*#Creating a variable called 'simulation1'.simulation1=cfmdarts.dart_simulation(2,1.5,21)##Outputs the final score from simulation1print(simulation1)Output:13Creating a Dartboard Plot of the score using Displayfromcfmdartsimport*#Creating a new Coordinates object.Coord1=cfmdarts.Coordinates(2,1.5,22)##These two lines below print out the respective r and theta values##of the coordinates object.print(Coord1.r())print(Coord1.theta())###This function displays a graphical image of a dartboard with the score###Being displayed as a red cross.cfmdarts.display_dartboard(Coord1.r(),Coord1.theta())Output in the terminal and the following display:0.0671940186931568522.54128468531238Example of a dart simulation that has an incorrect input case with tilt_angle being an invalid inputfromcfmdartsimport*#Creating a variable called 'simulation1'.simulation1=cfmdarts.dart_simulation(-91,2,29)##Outputs the final score from simulation1print(simulation1)Output:nullshot,pleaseensurethetiltandswivelanglesarebothbetween-90and90,andthatthevelocityispositiveTestingTo test the code:$pythontest_cfmdarts.pyExplanationPhase I - Projectile In 3DWe must first consider the 2-dimensional plane (x,y) in which our dart
travels through. Doing, we can model the trajectory of the dart using projectile motion
in order to obtain the range, height, and shift of the dart relative to the bullseye. We can say that air resistance of the dart is negligible.Phase II - Geometry Of DartboardDetermining the score is precisely the same as determining the position at which the dart landed
on the dartboard. We will obtain (via the specified throw) 2 distances relative to the distance from the
bullseye.
Using these 2 values as Cartesian coordinates, we can translate the position into polar form r, θ via similar methods to determining the modulus and argument of a complex number. See the Coordinates class in how this was achieved.LicenseMIT