top of page
Writer's picturejesskesson

Sine, Cosine and Tangent Calculator

We looked at a calculator that could calculate any kind of trigonometry, including the Sine and Cosine rule. I went through the code and wrote notes about what each part of the code was doing. As I was doing this, I came across in a pattern in the code. It is mostly if-else statements to filter down the results until a correct method is worked out.


In this screenshot, I explain simply what each line of code is doing, and it is mostly the same over, which makes it easier to understand. This is a system of if-else statements that is designed to always find an answer. For example, in the first elif statement, what's it's saying is that if the Opposite is 0, then that's what being calculated. The angle will be turned into a radian and then multiplied by the hypotenuse, before being turned back into degrees.


The rest of the code is very much the same thing. I am having problems getting the screenshots on to a readable size, however these will have to do for now.


(Sorry for the small text, you might not be able to read it)









1 view0 comments

Recent Posts

See All

Comments


bottom of page