ballistics 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/ballistics/ballistics.c +5 -3
- data/spec/ballistics/atmosphere_spec.rb +0 -5
- data/spec/ballistics/zero_spec.rb +1 -1
- data/spec/ballistics_spec.rb +55 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4ba3d0aec12eee3a0bada1d015678f2267b6e6c
|
4
|
+
data.tar.gz: fe2fe7e3cceeff32a6c978fa03cda97772bcced2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73c3a515f55a85f155741e103aa8b9ebb1afeb2fc33ae27b8cde926ee1eb651de505c0df974de3c8130a92ef31bbf3f558a4cd2b8cdc109b427805ffd065c0da
|
7
|
+
data.tar.gz: d01176c7f9f3770846cd694567f957404ddbe434929f4fbc7c3c09bcbcc3fb19a767fd5b63979eaa1fac7845a8912544c6871ce2cf6c93481064ef8d9f66e8ce
|
data/ext/ballistics/ballistics.c
CHANGED
@@ -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
|
-
|
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(
|
83
|
-
rb_hash_aset(entry, rb_str_new2("moa_windage"), rb_float_new(
|
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++;
|
data/spec/ballistics_spec.rb
CHANGED
@@ -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:
|
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
|
20
|
-
expect(result_array[
|
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[
|
23
|
-
expect(result_array[
|
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
|