ballistics 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afee8804afd6b1d6c21c972cd12e6a56e0b9a90c
4
- data.tar.gz: 13a04e599ba668fac98d97addf2f6a9d31ba2ee2
3
+ metadata.gz: a4ba3d0aec12eee3a0bada1d015678f2267b6e6c
4
+ data.tar.gz: fe2fe7e3cceeff32a6c978fa03cda97772bcced2
5
5
  SHA512:
6
- metadata.gz: 76f6b65bd5991e05270c03cb7b15d89c67aa5264889fba200fc887135942c3427795849dfa89752a00cd0494fe009da06d7aa6b8e9249445a636918e08fef6fe
7
- data.tar.gz: 611d4d8ea5f81dd93067b10904487bc393464b2388e6bdcfb280d734490d96c79f510b67430541a76f921d461e5d9da6c20337b2800d9445018da1822521b3b8
6
+ metadata.gz: 73c3a515f55a85f155741e103aa8b9ebb1afeb2fc33ae27b8cde926ee1eb651de505c0df974de3c8130a92ef31bbf3f558a4cd2b8cdc109b427805ffd065c0da
7
+ data.tar.gz: d01176c7f9f3770846cd694567f957404ddbe434929f4fbc7c3c09bcbcc3fb19a767fd5b63979eaa1fac7845a8912544c6871ce2cf6c93481064ef8d9f66e8ce
@@ -75,12 +75,14 @@ VALUE method_map_trajectory(VALUE self, VALUE drag_function, VALUE drag_coeffici
75
75
 
76
76
  if (x/3>=n){
77
77
  VALUE entry = rb_hash_new();
78
- rb_hash_aset(entry, rb_str_new2("range"), rb_float_new(x/3));
78
+ double windage_value = Windage(crosswind,Vi,x,t+dt);
79
+ double moa_windage_value = windage_value / (((x/3) / 100) * 1.0465);
80
+ rb_hash_aset(entry, rb_str_new2("range"), rb_float_new((int)(x/3)));
79
81
  rb_hash_aset(entry, rb_str_new2("path"), rb_float_new(y*12));
80
82
  rb_hash_aset(entry, rb_str_new2("moa_correction"), rb_float_new(-RadtoMOA(atan(y/x))));
81
83
  rb_hash_aset(entry, rb_str_new2("time"), rb_float_new(t+dt));
82
- rb_hash_aset(entry, rb_str_new2("windage"), rb_float_new(Windage(crosswind,Vi,x,t+dt)));
83
- rb_hash_aset(entry, rb_str_new2("moa_windage"), rb_float_new(RadtoMOA(atan(rb_hash_aref(entry, rb_str_new2("windage"))))));
84
+ rb_hash_aset(entry, rb_str_new2("windage"), rb_float_new(windage_value));
85
+ rb_hash_aset(entry, rb_str_new2("moa_windage"), rb_float_new(moa_windage_value));
84
86
  rb_hash_aset(entry, rb_str_new2("velocity"), rb_float_new(v));
85
87
  rb_ary_push(result_array, entry);
86
88
  n++;
@@ -7,9 +7,4 @@ describe Ballistics::Atmosphere do
7
7
  it 'returns a corrected BC' do
8
8
  expect(atmosphere.correct_ballistic_coefficient(0.338).round(3).to_f).to eq 0.392
9
9
  end
10
-
11
- it 'has working accessors' do
12
- expect(atmosphere.temperature).to eq 40
13
- end
14
-
15
10
  end
@@ -13,7 +13,7 @@ describe Ballistics::Zero do
13
13
  }
14
14
  end
15
15
 
16
- it 'returns the correct value' do
16
+ it 'returns the expected value' do
17
17
  expect(Ballistics::Zero.calculate_zero_angle(options).round(6)).to eq 0.227188
18
18
  end
19
19
  end
@@ -7,8 +7,10 @@ describe Ballistics do
7
7
  drag_coefficient: 0.5,
8
8
  velocity: 2850,
9
9
  sight_height: 1.6,
10
+ wind_speed: 10,
11
+ wind_angle: 90,
10
12
  zero_range: 200,
11
- max_range: 400,
13
+ max_range: 1000,
12
14
  environment: environment)
13
15
  end
14
16
 
@@ -16,10 +18,58 @@ describe Ballistics do
16
18
  expect(environment).to be_an_instance_of Ballistics::Atmosphere
17
19
  end
18
20
 
19
- it 'returns an array of queryable ballistic objects' do
20
- expect(result_array[400]['path'].round(1).to_f).to eq -20.1
21
+ it 'returns the range' do
22
+ expect(result_array[100]['range'].round(1)).to eq 100
23
+ expect(result_array[200]['range'].round(1)).to eq 200
24
+ expect(result_array[300]['range'].round(1)).to eq 300
25
+ expect(result_array[400]['range'].round(1)).to eq 400
26
+ expect(result_array[500]['range'].round(1)).to eq 500
27
+ expect(result_array[1000]['range'].round(1)).to eq 1000
28
+ end
29
+
30
+ it 'returns the path' do
31
+ expect(result_array[100]['path'].round(1)).to eq 1.6
32
+ expect(result_array[200]['path'].round(1)).to eq 0
33
+ expect(result_array[300]['path'].round(1)).to eq -7
34
+ expect(result_array[400]['path'].round(1)).to eq -20.1
35
+ expect(result_array[500]['path'].round(1)).to eq -40.1
36
+ expect(result_array[1000]['path'].round(1)).to eq -282.5
37
+ end
38
+
39
+ it 'returns the velocity' do
40
+ expect(result_array[100]['velocity'].to_i).to eq 2691
41
+ expect(result_array[200]['velocity'].to_i).to eq 2538
42
+ expect(result_array[300]['velocity'].to_i).to eq 2390
21
43
  expect(result_array[400]['velocity'].to_i).to eq 2246
22
- expect(result_array[400]['moa_correction'].round(1).to_f).to eq 4.8
23
- expect(result_array[100]['moa_correction'].round(1).to_f).to eq -1.5
44
+ expect(result_array[500]['velocity'].to_i).to eq 2108
45
+ expect(result_array[1000]['velocity'].to_i).to eq 1500
46
+ end
47
+
48
+ it 'returns the moa correction' do
49
+ expect(result_array[100]['moa_correction'].round(1)).to eq -1.5
50
+ expect(result_array[200]['moa_correction'].round(1)).to eq 0
51
+ expect(result_array[300]['moa_correction'].round(1)).to eq 2.2
52
+ expect(result_array[400]['moa_correction'].round(1)).to eq 4.8
53
+ expect(result_array[500]['moa_correction'].round(1)).to eq 7.7
54
+ expect(result_array[1000]['moa_correction'].round(1)).to eq 27
24
55
  end
56
+
57
+ it 'returns the windage' do
58
+ expect(result_array[100]['windage'].round(1)).to eq 0.6
59
+ expect(result_array[200]['windage'].round(1)).to eq 2.3
60
+ expect(result_array[300]['windage'].round(1)).to eq 5.2
61
+ expect(result_array[400]['windage'].round(1)).to eq 9.4
62
+ expect(result_array[500]['windage'].round(1)).to eq 15.2
63
+ expect(result_array[1000]['windage'].round(1)).to eq 71.3
64
+ end
65
+
66
+ it 'returns the moa correction for wind drift windage' do
67
+ expect(result_array[100]['moa_windage'].round(1)).to eq 0.5
68
+ expect(result_array[200]['moa_windage'].round(1)).to eq 1.1
69
+ expect(result_array[300]['moa_windage'].round(1)).to eq 1.6
70
+ expect(result_array[400]['moa_windage'].round(1)).to eq 2.3
71
+ expect(result_array[500]['moa_windage'].round(1)).to eq 2.9
72
+ expect(result_array[1000]['moa_windage'].round(1)).to eq 6.8
73
+ end
74
+
25
75
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ballistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Staton