Skip to main content

cfmdarts

cfmdarts is a Python library that simulates the projectile motion of darts.

Table of Contents

  1. Introduction
  2. Installation
  3. Tutorials
  4. How To Guides
  5. Testing
  6. Explanation
  7. License

Introduction

This project has an extremely trivial goal. Simply input 3 values relating to the throw of a dart

  • tilt angle
  • swivel 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.

Installation

Use the package manager pip to install cfmdarts.

pip install cfmdarts

NOTE: It is recommended to have a Python version which is greater that 3.6 to be installed.

Tutorial

In order to use cfmdarts is really simple. To use in your project, you type

from cfmdarts import*

How To Guides

These next guides are simple pieces of code to get you started using cfmdarts.

Creating a new Projectile object.

from cfmdarts import*

#Creating a new Projectile object called Object1
#with tilt_angle=2, swivel_angle=1.5 and initial_velocity=21

Object1 = cfmdarts.Projectile(2, 1.5, 21)

Outputting a new Projectile objects range, height and shift values.

from cfmdarts import*

#Creating a new Projectile object called Object1
#with tilt_angle=2, swivel_angle=1.5 and initial_velocity=21

Object1 = cfmdarts.Projectile(2,1.5,21)

##This outputs the follow
print(Object1.range())
print(Object1.height())
print(Object1.shift())

Output:

2.370812418203357
0.02019783552359672
0.06206063411897303

Creating a coordinates object to calculate and output the cartesian and polar coordinates

from cfmdarts import*

#Creating a coordinates object called coord1
#with tilt_angle=2, swivel_angle=1.5 and initial_velocity=21

Coord1 = 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.

from cfmdarts import*

#Creating a variable called 'simulation1'.
simulation1 = cfmdarts.dart_simulation(2, 1.5, 21)

##Outputs the final score from simulation1
print(simulation1)

Output:

13

Creating a Dartboard Plot of the score using Display

from cfmdarts import*

#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.06719401869315685
22.54128468531238

Screenshot

Example of a dart simulation that has an incorrect input case with tilt_angle being an invalid input

from cfmdarts import*

#Creating a variable called 'simulation1'.
simulation1 = cfmdarts.dart_simulation(-91, 2, 29)

##Outputs the final score from simulation1
print(simulation1)

Output:

null shot, please ensure the tilt and swivel angles are both between -90 and 90, and that the velocity is positive

Testing

To test the code:

$ python test_cfmdarts.py

Explanation

Phase I - Projectile In 3D

We 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 Dartboard

Determining 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.

License

MIT

Metadata

Release files for cfmdarts 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cfmdarts 0.2.0
File Size Uploaded Provenance
cfmdarts-0.2.0.tar.gz 49.9 kB Without provenance Details

Release files / cfmdarts-0.2.0.tar.gz

Download URL cfmdarts-0.2.0.tar.gz
Size 49.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8582fe3ebc76a820f2c20f69c7091464b9a102827a8b87aea3b8135dab2c4126
BLAKE2b-256 checksum
How to use checksums
fa5b7ed56c49922868291a7d9ea770f082a73169ce4ed3cff811c73c32e0f0c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.8

Security for cfmdarts 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page