Almost everything I do has coordinates in it: projected, geographic, arbitrary - and for as long as I've been coding in Python I've been slowly storing my snippets of code and building on them as I reuse them. One of the tasks I usually have to do when starting a new Python project is copy over my math code. Once I've built on it, I then have to decide whether or not I'm going to retrospectively fit the new code into my old projects - you can see how this would just be a headache to consider let alone implement!
This week I have started the process of releasing my code as Open Source under an MIT license and wrapping it all up in a clean module to be uploaded to the Python Package Index library so anyone can use it.
History Lesson Please :)
Sometime ago - when I was young (18), dumb (very), and dopey at math (and life in general) - I was training to be an Artillery Surveyor, in the corps of Royal Australian Artillery, in the Australian Regular Army. We had to load various programs on our Hewlett Packard HP41 CV Calculators using a magnetic card strip reader. Now, to be fair - these calculators were already ancient when I joined the Army! I didn't know what was on the magnetic strips or how they worked, only that they made my life as an Artillery Surveyor much easier. Later in life as I slowly improved my maths, then programming, then kicked ass at both - I would use these mystery programs as a bench mark for my own learning.
That's great - code please!
The code I have currently committed is quite basic, it doesn't take into account scale factors or curvature of the earth (suits the flat-earthers no doubt) but can be used for 3d distances, differences in elevations etc. Most of the basic functions that could be performed on an Artillery Surveyor HP41Cv programmed calculator are existent but not yet complete - ie CBD, BDC, DMS, TRAV and so on.
I won't go into the full breakdown of the module because I've already released that on GitHub (wait a few weeks before it's completed) here's some code snippets.
The big question, who would use this and where? A couple of basic examples of how this code can be used are;
- Web based calculations - if you've a Django site this will fit right in.
- Games - yep, already built a game engine that allows for autonomous robots to run around and shoot each other using this very code.
- General calculations - my previously detailed Bore Calculator used this code to calculate 3D points before spitting out the setout file and the 3D model.
Literally any calculation suitable enough to be done on a flat plane can utilise this library of mathematical goodness! There's a bit of work to be done before it's ready to be used as a plugin, expect plenty of updates on this subject though as I deploy and use this pretty handy library.