Although I love logic, I ironically don’t like math very much. Working conceptually with my drone has forced me to do a lot of basic trigonometry, though, so I ended up getting lazy and writing a Python package that does a lot of the legwork for me.
The package really isn’t worth mentioning. All it provides is a single function: solve(). solve takes a side and an angle from a triangle, as well as the requested side. If you leave it on its default settings, it returns the value of the side you’re looking for. However, since I use the package for developing performance-sensitive applications, I don’t want to actually have to call it and have the program spend time figuring out what I, the dumb user, is wanting. Therefore I added a second mode that returns a string of the equation that I should use to find the side I want. That way I don’t have to constantly think about sin, cosine, etc. It looks like this (taken from the PyPI page):
>>> from triangles import solve >>> solve("adjacent", 60, hypotenuse=1000) 500.0000000000001 >>> solve("opposite", 53, adjacent=7) 9.289313751342869 >>> solve("hypotenuse", 68, opposite=70) 75.49743198743084
The funny thing is that, due to laziness, I decided to upload the package to PyPI and install it with pip so I wouldn’t have to type in the setup.py commands myself. I know, I know, it’s a bit more work putting the package together, but I’m never sure when I write something that I’ll absolutely never want to expand it in the future, so I tend to organize my code into packages and document it anyway. Plus, who knows who’ll stumble upon it and perhaps get some use out of it later. So after writing the code on the train in the middle of the week, I uploaded it to PyPI, installed it, and forgot about it.
That is, until I looked at it today and noticed that more than 700 people have downloaded it, even though I hadn’t announced it anywhere! So I guess I’m not the only person who doesn’t like SOHCAHTOA. Or however that saying goes.
The moral of the story? You never know when something will be helpful to somebody else, so make everything available! It’ll give you a warm feeling in your heart.