Calculating trig functions to more than two decimal places in javascript
Hi all,
I'm trying to boost my game in terms of SL360 development and I'm creating a simple function where the user turns a dial to change an angle, and the sine, cosine and tangent of the angle is automatically calculated.
I've created the tool fine and it wors as it should; however, it only calculates the trig functions to two decimal places and i'd like it to calculate them to four decimal places.
Here is the javascript I created that does this (notes were put in for my benefit):
let player = GetPlayer();
let degrees = player.GetVar("Angle"); //retrieves the value of the angle from SL360
let radians = degrees * (Math.PI/180); //converts to radians to calculate the sine of the variable "Angle"
let sinAngle = Math.sin(radians);//calculates the sine of "Angle"
let cosAngle = Math.cos(radians); //calculates the cosine of "Angle"
let tanAngle = Math.tan(radians); //calculates the tangent of "Angle"
player.SetVar("Sine",sinAngle); //outputs the value of sinAngle to the SL360 variable of "Sine"
player.SetVar("Cosine",cosAngle); //outputs the value of cosAngle to the SL360 variable of "Cosine"
player.SetVar("Tangent",tanAngle);//outputs the value of tanAngle to the SL360 variable of "Tangent"
It works fine, but I just need to know how to calculate the values to more than two decimal places. i've tried using .toFixed(), but haven't had any luck with it.
any help would be appreciated.
Regards,
Doug