SohCahToa
Time to get back to the basics. I use trig at work, and at home in PyGame\Processing, but I like understanding the fundamentals of how it works. So I sat down one afternoon and made up a “SohCahToa” PyGame program that really illustrates (to me at least) what the values behind sine, cosine and tangent mean. They are after all, ratios of the sides of a triangle.
- Windows executable. Find the zipped version here:
- The source code is online here, feel free to grab it:
- http://www.akeric.com/python/sohCahToa01.py
- I built it with Python 2.6.2 and PyGame 1.9.1, but nothing fancy is going on with either, so it should work with older versions.
So the mnemonic device is “Soh-Cah-Toa”, which means:
- Sine = Opposite / Hypotenuse
- Cosine = Adjacent / Hypotenuse
- Tangent = Opposite / Adjacent
I wanted a visual way to see this in action, and that’s what this little program does:
It plots a triangle defined by the opposite, adjacent, and hypotenuse sides. As time goes by ‘degrees \ radians \ pi’ values increase, and the triangle changes. The lengths of each side are plotted, and at the bottom, the math behind the sin, cos, and tan are shown in real-time.
———————————————————————
SoftPedia has added SohCahToa to their site as well:
No comments yet.