11# Darts (Draft)
22
33Steps
4- - Comstruct a set of geometries representimg a dartboard with individual sector scores
4+ - Construct a set of geometries representing a dartboard with individual sector scores
55- Develop a model of the dart trajectory with probability density distribution
66- Use integration over each geometry to determine the probabilities of particular outcomes
77- Calculate expected value for the throw, repeat for other distributions to compare strategies
88
9+ Note: can use ` @setup darts ` block to hide some implementation code
10+
911``` @example darts
12+ # using Distributions
1013using Meshes
1114using MeshIntegrals
1215using Unitful
1316```
1417
1518## Modeling the Dartboard
1619
17- Model the geometries
20+ Define a dartboard coordinate system
21+ ``` @example darts
22+ dartboard_center = Point(0u"m", 0u"m", 1.5u"m")
23+ dartboard_plane = Plane(dartboard_center, Meshes.Vec(1, 0, 0))
24+
25+ function point(r::Unitful.Length, ϕ)
26+ t = ustrip(r, u"m")
27+ dartboard_plane(t * sin(ϕ), t * cos(ϕ))
28+ end
29+ ```
30+
31+ Model the bullseye region
32+ ``` @example darts
33+ bullseye_inner = (geometry = Circle(dartboard_plane, 6.35u"mm"), points = 50)
34+ bullseye_outer = (geometry = Circle(dartboard_plane, 16u"mm"), points = 25)
35+ # TODO subtract center circle region from outer circle region -- or replace with another annular geometry
36+ ```
37+
38+ Model the sectors
1839``` @example darts
19- center = Point(0u"m", 0u"m", 1.5u"m")
20- point(r, ϕ) = center + Meshes.Vec(0u"m", r*sin(ϕ)*u"m", r*cos(ϕ)*u"m")
40+ # Scores on the Board
41+ ring1 = [20, 1, 18, 4, 13, 6, 10, 15, 2, 17, 3, 19, 7, 16, 8, 11, 14, 9, 12, 5]
42+ ring2 = 3 .* ring1
43+ ring3 = ring1
44+ ring4 = 2 .* ring1
45+ board_points = hcat(ring1, ring2, ring3, ring4)
2146
47+ # Locations
48+ sector_width = 2π/20
49+ phis_a = range(0, 2π, 20) .- sector_width/2
50+ phis_b = range(0, 2π, 20) .+ sector_width/2
51+ rs_inner = [16, 99, 107, 162]u"mm"
52+ rs_outer = [99, 107, 162, 170]u"mm"
53+ ```
54+
55+ Define a struct to manage sector data
56+ ``` @example darts
2257struct Sector{L, A}
2358 r_inner::L
2459 r_outer::L
@@ -35,16 +70,17 @@ function to_ngon(sector::Sector; N=8)
3570end
3671```
3772
38- Point system
39- ``` @example darts
40- sector_width = 2pi/20
41- ring1 = [20, 1, 18, 4, 13, 6, 10, 15, 2, 17, 3, 19, 7, 16, 8, 11, 14, 9, 12, 5]
42- ring2 = 3 .* ring1
43- ring3 = ring1
44- ring4 = 2 .* ring1
73+ ## Modeling the Dart Trajectory
4574
46- bullseye_inner = (points=50,)
47- bullseye_outer = (points=25,)
75+ Define a probability distribution for where the dart will land
76+ ```
77+ dist = MvNormal(μs, σs)
4878```
4979
50- ## Modeling the Dart Trajectory
80+ Integrand function is the distribution's PDF value at any particular point
81+ ```
82+ function integrand(p::Point)
83+ v_error = dist_center - p
84+ pdf(dist, v_error)
85+ end
86+ ```
0 commit comments