Skip to content

Commit a67472c

Browse files
author
Mark Gardner
committed
Added ability to calculate initial velocity based on projection angle and distance.
Fixed kinetic energy calc doubling the correct value. Fixed JSON output bug.
1 parent 78290ce commit a67472c

File tree

7 files changed

+145
-352
lines changed

7 files changed

+145
-352
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
GOPATH=/Users/runeimp/dev/apps/ballistic
2-
VERSION=0.4.2
2+
VERSION=0.5.0

Justfile

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ _build-app:
2020
just build-win32
2121
else
2222
just build-{{os()}}
23+
if [ -d "${HOME}/dev/bin" ]; then
24+
cp bin/{{os()}}/ballistic "${HOME}/dev/bin/"
25+
fi
2326
fi
2427

2528
@build arg='app':
@@ -234,9 +237,9 @@ _list-dir path='.':
234237

235238

236239
# Run the app
237-
run +args='':
238-
@just term-wipe
239-
@just _run {{args}}
240+
@run +args='':
241+
just term-wipe
242+
just _run {{args}}
240243

241244
@_run +args='':
242245
# BALLISTIC_WEIGHT=grams bin/{{os()}}/ballistic
@@ -306,15 +309,15 @@ _term-lw label:
306309
term-wipe:
307310
#!/usr/bin/env sh
308311
if [ '{{os()}}' = 'macos' ]; then
309-
just _term-wipe
312+
osascript -e 'tell application "System Events" to keystroke "k" using command down'
313+
elif [ -f `which tput` ]; then
314+
tput reset
315+
elif [ -f `which reset` ]; then
316+
reset
310317
else
311318
just _term-clear
312319
fi
313320

314-
_term-wipe:
315-
#!/usr/bin/osascript
316-
tell application "System Events" to keystroke "k" using command down
317-
318321

319322
# Test all examples
320323
test:

README.md

Lines changed: 32 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Ballistic v0.4.2
1+
Ballistic v0.5.0
22
================
33

44
Command line ballistics calculator
@@ -66,6 +66,28 @@ $ ballistic --mass 42g --draw-weight 80lb --draw-length 0.72m --json --pretty
6666
}
6767
```
6868

69+
### Calculate initial velocity and MPBR based on projection angel and distance (on a horizontal plan)
70+
71+
```text
72+
$ ballistic -a 45 -d 100m
73+
74+
Projectile Velocity: 790.133355 meters per second
75+
Max Point Blank Range: 239.365366 meters
76+
77+
```
78+
79+
#### Calculate everything by adding projectile mass
80+
81+
```text
82+
$ ballistic -a 45 -d 100m -m 300gr
83+
84+
Projectile Velocity: 790.133355 meters per second
85+
Projectile Energy: 6,068.197170 joules
86+
Projectile Momentum: 15.359932 meter kilogram per second
87+
Max Point Blank Range: 239.365366 meters
88+
89+
```
90+
6991
### Help Info
7092

7193
```text
@@ -78,17 +100,19 @@ USAGE:
78100
ballistic [global options]
79101
80102
VERSION:
81-
0.4.2
103+
0.5.0
82104
83105
GLOBAL OPTIONS:
84-
--debug, -d Output debug info
106+
--debug, -D Output debug info
85107
--draw-length LENGTH, --length LENGTH, -l LENGTH Bow or sling shot draw LENGTH. Used to calculate projectile velocity, energy, etc.
86108
--draw-weight WEIGHT, --weight WEIGHT, -w WEIGHT Bow or sling shot draw WEIGHT. Used to calculate projectile velocity, energy, etc.
87109
--json, -j Output JSON data
88110
--locale LOCALE, --local LOCALE The LOCALE to format number output for. (default: "en_US") [$LC_CTYPE, $LANG]
89111
--precision PRECISION, --float PRECISION, -f PRECISION The output floating point PRECISION (numbers after decimal mark). (default: "6")
90112
--pretty-print, --pretty, -p Pretty printed JSON output
91113
--projectile MASS, --mass MASS, -m MASS Projectile MASS (weight). Used to calculate projectile velocity, energy, etc.
114+
--projectile-range value, --distance value, -d value The distance the projectile traveled
115+
--projection-angle value, --angle value, -a value The projection angle or trajectory of projectile
92116
--radius RADIUS, -r RADIUS The RADIUS of the target area. Used to calculate MPBR (Maximum Point Blank Range). (default: "225mm")
93117
--velocity VELOCITY, -v VELOCITY The projectile VELOCITY (speed). Used to calculate projectile energy, momentum, etc.
94118
--help, -h Output this help info
@@ -97,6 +121,9 @@ GLOBAL OPTIONS:
97121
VALUE SUFFIXES:
98122
All input values may be suffixed to allow for broader input selection.
99123
124+
ANGEL
125+
d, deg, degree, degrees
126+
r, rad, radian, radians
100127
LENGTH
101128
c, cm, centi, centimeter, centimeters
102129
f, ft, foot, feet
@@ -143,7 +170,7 @@ This is my choice over using `make` to facilitates building the binaries and cre
143170
Internationalization/Locale
144171
---------------------------
145172

146-
Ballistic can format the human output numbers per locale norms. It currently checks for locale settings via the environment variables LC_CTYPE and LANG. It also allows you to specify a locale such as `en_CA` or `FR-CA` for English or French Canada for instance or simply `EN` for general English speakers, `DE` the German language or country, etc. via the `--locale` option.
173+
Ballistic can format the human output numbers per locale norms. It currently checks for locale settings via the environment variables `LC_CTYPE` and `LANG`. It also allows you to specify a locale such as `en_CA` or `FR-CA` for English or French Canada for instance or simply `EN` for general English speakers, `DE` the German language or country, etc. via the `--locale` option.
147174

148175
### Locales Supported
149176

@@ -190,112 +217,11 @@ Here be Dragons! (my research)
190217
- [SI (International System of Units) - Wikipedia][]
191218

192219

193-
### Symbols
194-
195-
| Category | Symbol | Unicode | Decimal | Escape | Numbers | Description |
196-
| :------: | :----: | :-----: | :-----: | :----: | :-----: | ----------- |
197-
| Comma | ' | U+0027 | `'` | `\u0027` | | [Unicode APOSTROPHE][] |
198-
| Comma | , | U+002C | `,` | `\u002C` | ✓ | [Unicode COMMA][] |
199-
| Comma | 𑑍 | U+01144D | `𑑍` | `\u01144D` | | [Unicode NEWA COMMA][] |
200-
| Comma | 𝪇 | U+01DA87 | `𝪇` | `\u01DA87` | | [Unicode SIGNWRITING COMMA][] |
201-
| Comma | ʽ | U+02BD | `ʽ` | `\u02BD` | | [Unicode MODIFIER LETTER REVERSED COMMA][] |
202-
| Comma | ̒ | U+0312 | `̒` | `\u0312` | | [Unicode COMBINING TURNED COMMA ABOVE][] |
203-
| Comma | ̔ | U+0314 | `̔` | `\u0314` | | [Unicode COMBINING REVERSED COMMA ABOVE][] |
204-
| Comma | ̕ | U+0315 | `̕` | `\u0315` | | [Unicode COMBINING COMMA ABOVE RIGHT][] |
205-
| Comma | ، | U+060C | `،` | `\u060C` | | [Unicode ARABIC COMMA][] |
206-
| Comma | ❛ | U+275B | `❛` | `\u275B` | | [Unicode HEAVY SINGLE TURNED COMMA QUOTATION MARK ORNAMENT][] |
207-
| Comma | ❜ | U+275C | `❜` | `\u275C` | | [Unicode HEAVY SINGLE COMMA QUOTATION MARK ORNAMENT][] |
208-
| Comma | ⸲ | U+2E32 | `⸲` | `\u2E32` | | [Unicode TURNED COMMA][] |
209-
| Comma | ⸴ | U+2E34 | `⸴` | `\u2E34` | | [Unicode RAISED COMMA][] |
210-
| Comma | ⹁ | U+2E41 | `⹁` | `\u2E41` | | [Unicode REVERSED COMMA][]. Used in Sindhi. |
211-
| Comma | 、 | U+3001 | `、` | `\u3001` | | [Unicode IDEOGRAPHIC COMMA][] |
212-
| Comma | ﹐ | U+FE50 | `﹐` | `\uFE50` | | [Unicode SMALL COMMA][] |
213-
| Comma | ﹑ | U+FE51 | `﹑` | `\uFE51` | | [Unicode SMALL IDEOGRAPHIC COMMA][] |
214-
| Comma | , | U+FF0C | `,` | `\uFF0C` | | [Unicode FULLWIDTH COMMA][] |
215-
| Comma | 、 | U+FF64 | `、` | `\uFF64` | | [Unicode HALFWIDTH IDEOGRAPHIC COMMA][] |
216-
| Decimal Mark | ٫ | U+066B | `٫` | `\u066B` | ✓ | [Unicode ARABIC DECIMAL SEPARATOR][] |
217-
| Decimal Mark | ⎖ | U+2396 | `⎖` | `\u2396` | Keyboard | [Unicode DECIMAL SEPARATOR KEY SYMBOL][]. Noted in [ISO/IEC 9995][ISO/IEC 9995 - Wikipedia] |
218-
| Decimal Mark? | ⸰ | U+2E30 | `⸰` | `\u2E30` | | [Unicode RING POINT][] |
219-
| Group Mark | ٬ | U+066C | `٬` | `\u066C` | ✓ | [Unicode ARABIC THOUSANDS SEPARATOR][] |
220-
| Interpunct | · | U+00B7 | `·` | `\u00B7` | ✓ | [Unicode MIDDLE DOT][] |
221-
| Interpunct | • | U+2022 | `•` | `\u2022` | | [Unicode BULLET][] |
222-
| Interpunct | ‣ | U+2023 | `‣` | `\u2023` | | [Unicode TRIANGULAR BULLET][] |
223-
| Interpunct | ∙ | U+2219 | `∙` | `\u2219` | | [Unicode BULLET OPERATOR][] |
224-
| Interpunct | ⋅ | U+22C5 | `⋅` | `\u22C5` | | [Unicode DOT OPERATOR][] |
225-
| Interpunct | ◦ | U+25E6 | `◦` | `\u25E6` | | [Unicode WHITE BULLET][] |
226-
| Interpunct | ⦁ | U+2981 | `⦁` | `\u2981` | Math | [Unicode Z NOTATION SPOT][] |
227-
| Interpunct | ⸱ | U+2E31 | `⸱` | `\u2E31` | | [Unicode WORD SEPARATOR MIDDLE DOT][] |
228-
| Misc. | 🍀 | U+1F340 | `🍀` | `\u1F340` | | [Unicode FOUR LEAF CLOVER][] |
229-
230-
<!--
231-
| | &#x____; | U+____ | `&#____;` | `\u____` | | [] |
232-
| | &#x____; | U+____ | `&#____;` | `\u____` | | [] |
233-
| | &#x____; | U+____ | `&#____;` | `\u____` | | [] |
234-
| | &#x____; | U+____ | `&#____;` | `\u____` | | [] |
235-
| | &#x____; | U+____ | `&#____;` | `\u____` | | [] |
236-
-->
237-
238-
239-
240-
### Formulas
241-
242-
Note: These formulas are here for my tracking purposes. They are not necessarily used in the app.
243-
244-
```
245-
PE = mass * gravity * height
246-
247-
Energy = pressure * volume / efficiency
248-
```
249-
250-
PE = Potential Energy
251-
252-
253-
- [PSI to Energy][]
254-
255-
256-
<!--
257-
[Unicode ____]: https://www.fileformat.info/info/unicode/char/____/
258-
[Unicode ____]: https://www.fileformat.info/info/unicode/char/____/
259-
[Unicode ____]: https://www.fileformat.info/info/unicode/char/____/
260-
-->
261220

262221
[`just`]: https://github.com/casey/just
263222
[Decimal Separator - Wikipedia]: https://en.wikipedia.org/wiki/Decimal_separator
264-
[ISO/IEC 9995 - Wikipedia]: https://en.wikipedia.org/wiki/ISO/IEC_9995
265223
[Decimal and Thousands Separators (International Language Environments Guide)]: https://docs.oracle.com/cd/E19455-01/806-0169/overview-9/
266224
[SI (International System of Units) - Wikipedia]: https://en.wikipedia.org/wiki/International_System_of_Units
267225
[ISO 31-0: Numbers - Wikipedia]: https://en.wikipedia.org/wiki/ISO_31-0#Numbers
268-
[PSI to Energy]: https://www.physicsforums.com/threads/psi-to-kw-conversion.700882/
269-
[Unicode APOSTROPHE]: https://www.fileformat.info/info/unicode/char/0027/
270-
[Unicode ARABIC COMMA]: https://www.fileformat.info/info/unicode/char/060C/
271-
[Unicode ARABIC DECIMAL SEPARATOR]: https://www.fileformat.info/info/unicode/char/066B/
272-
[Unicode ARABIC THOUSANDS SEPARATOR]: https://www.fileformat.info/info/unicode/char/066C/
273-
[Unicode BULLET OPERATOR]: https://www.fileformat.info/info/unicode/char/2219/
274-
[Unicode BULLET]: https://www.fileformat.info/info/unicode/char/2022/
275-
[Unicode COMBINING COMMA ABOVE RIGHT]: https://www.fileformat.info/info/unicode/char/0315/
276-
[Unicode COMBINING REVERSED COMMA ABOVE]: https://www.fileformat.info/info/unicode/char/0314/
277-
[Unicode COMBINING TURNED COMMA ABOVE]: https://www.fileformat.info/info/unicode/char/0312/
278-
[Unicode COMMA]: https://www.fileformat.info/info/unicode/char/002C/
279-
[Unicode DECIMAL SEPARATOR KEY SYMBOL]: https://www.fileformat.info/info/unicode/char/2396/
280-
[Unicode DOT OPERATOR]: https://www.fileformat.info/info/unicode/char/22C5/
281-
[Unicode FOUR LEAF CLOVER]: https://www.fileformat.info/info/unicode/char/1F340/
282-
[Unicode FULLWIDTH COMMA]: https://www.fileformat.info/info/unicode/char/FF0C/
283-
[Unicode HALFWIDTH IDEOGRAPHIC COMMA]: https://www.fileformat.info/info/unicode/char/FF64/
284-
[Unicode HEAVY SINGLE COMMA QUOTATION MARK ORNAMENT]: https://www.fileformat.info/info/unicode/char/275C/
285-
[Unicode HEAVY SINGLE TURNED COMMA QUOTATION MARK ORNAMENT]: https://www.fileformat.info/info/unicode/char/275B/
286-
[Unicode IDEOGRAPHIC COMMA]: https://www.fileformat.info/info/unicode/char/3001/
287-
[Unicode MIDDLE DOT]: https://www.fileformat.info/info/unicode/char/00B7/
288-
[Unicode MODIFIER LETTER REVERSED COMMA]: https://www.fileformat.info/info/unicode/char/02BD/
289-
[Unicode NEWA COMMA]: https://www.fileformat.info/info/unicode/char/1144D/
290-
[Unicode RAISED COMMA]: https://www.fileformat.info/info/unicode/char/2E34/
291-
[Unicode REVERSED COMMA]: https://www.fileformat.info/info/unicode/char/2E41/
292-
[Unicode RING POINT]: https://www.fileformat.info/info/unicode/char/2E30/
293-
[Unicode SIGNWRITING COMMA]: https://www.fileformat.info/info/unicode/char/1DA87/
294-
[Unicode SMALL COMMA]: https://www.fileformat.info/info/unicode/char/FE50/
295-
[Unicode SMALL IDEOGRAPHIC COMMA]: https://www.fileformat.info/info/unicode/char/FE51/
296-
[Unicode TRIANGULAR BULLET]: https://www.fileformat.info/info/unicode/char/2023/
297-
[Unicode TURNED COMMA]: https://www.fileformat.info/info/unicode/char/2E32/
298-
[Unicode WHITE BULLET]: https://www.fileformat.info/info/unicode/char/25E6/
299-
[Unicode WORD SEPARATOR MIDDLE DOT]: https://www.fileformat.info/info/unicode/char/2E31/
300-
[Unicode Z NOTATION SPOT]: https://www.fileformat.info/info/unicode/char/2981/
226+
301227

0 commit comments

Comments
 (0)