Radian to degree: var Degrees = Radian * (180 / Math.PI)
Degree to transform var bval=Math.sin(45*Math.PI / 180);
Transform to angle var angle = Math.round(Math.asin(bval) * (180/Math.PI));
Degree to radian: var Radians = Degree * Math.PI/180
The above steps tried with the below code with values "-3.17934" & "-0.9998"
`<script>
console.log("--------------------------------");
//var rad2="-3.17934";//-3.17934
var rad2="-0.9998";//-0.9998
console.log("First radian: "+rad2);
var rad2angle = rad2 * (180/Math.PI);
console.log("2 rad2angle: "+rad2angle);
var tt = Math.sin(rad2angle*Math.PI / 180);
console.log("3 To Transform: "+tt);
var t2angle = Math.round(Math.asin(tt) * (180/Math.PI));
console.log("2 t2angle: "+t2angle);
var angle2radian = t2angle * Math.PI/180;
console.log("Last radian: "+angle2radian);
</script>`
Thanks in Advance.
I tried with above code given in detail area.
While testing a script I realized that there was a problem for values greater than PI/2 or less than -PI/2. So I modified the script accordingly and it works even for the value "-3.17934"
This is the script I use to test
<script>
var listeRadian = [-0.50,-1,-1.5,-2,0.50,1,1.5,2];
// For Each Value of Radian
for(i=0;i<listeRadian.length;i++)
{
// Extraction
let radianValue = listeRadian[i];
console.log("Radian Value : "+radianValue);
// Calculate Sinus
var sinus = Math.sin(radianValue);
console.log("Angle : "+radianValue*(180/Math.PI));
console.log("Sinus : "+sinus);
// Calculate Sinus Inv
var sinusInv = (Math.asin(sinus) * (180/Math.PI));
if(radianValue>Math.PI/2) sinusInv = 180-sinusInv;
if(radianValue<(Math.PI/2)*-1) sinusInv = (180+sinusInv)*-1;
console.log("Sinus Inv : "+sinusInv);
// Calculate Radian
var radianCalc = sinusInv * Math.PI/180;
console.log("Radian Calc : "+radianCalc);
console.log("\n");
}
// End - For Each Value of Radian
</script>
Hoping that my answer and my remark on PI/2 can help you.
Information about asin() function: Here
I have modified the code & i got the proper output. Thanks everyone.
<script>
console.log("--------------------------------");
var rad2="-0.9998";
console.log("1- Radian Value: "+rad2);
var rad2angle = rad2 * (180/Math.PI);
console.log("2- Radian to Angle: "+rad2angle);
var cos=Math.cos(rad2angle*Math.PI / 180);
var sin=Math.sin(rad2angle*Math.PI / 180);
var catrans = [];
const trans = [cos, sin, -sin, cos, 0, 0];
console.log("3- Form Transform: "+trans.toString());
var tt= Math.atan2(sin,cos);
var angle2radian = tt * 180/Math.PI;
console.log("2- Transform to Angle: "+angle2radian);
console.log("1- Angle to radian: "+tt);
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.