JavaScript Math.sin and Math.cos return wrong values

furasarkfigue

New Member
i'm developing a simple application to help my math teacher to teach about trigonometry. The application is nothing but a circle where the angle keeps spinning and shows the variation of the Sin and Cos. Simple as hell.This is what i have so far:
V0bTL.png
And this is what i want to achieve
70PMq.png
(notice the green part representing the cos).Everything is being built through CSS. I needed to calculate the height and the width of the green triangle so i could display it, i tought it would be as simple as calculating the sin and the cos and just multiplying it by 200(my circle radius in px).But for some reason js is giving me inaccurate values for the sin and cos.For example, it gives right values if my angle is 0(cos: 1, sen: 0). But if i use an angle like 90, it will not return the right values, as shows the screenshot below:
NzCo4.png
This is my code so far(reduced for readability)\[code\]function trig(){ [...] this.radianMultiplier = Math.PI / 180; this.setDegree = function(degree) { [...] $('#h').html( Math.sin(degree * this.radianMultiplier) ); $('#w').html( Math.cos(degree * this.radianMultiplier) ); }}\[/code\]Any thoughts on what might be happening?
 
Top