g2r(g: Number);
g. Angle in radians.
The g2r method converts degrees to radians.
This method returns a Number type value.
To execute the example, the HTML page must contain links to the PP.js and PP.GraphicsBase.js scenario files. Convert the 45°, 60° and 90° angles to radians:
// Determine function for transforming degrees to radians
var toRadiant = function (g) {
if (g != null) {
if (PP.isNumber(g)) {
/* If parameter is a number,
transform the specified value to radians */
return PP.g2r(g);
} else {
/* Otherwise generate an error with a message about invalid type of argument */
throw PP.ArgumentException("Wrong type of argument", this);
}
} else {
// Function parameter cannot be null
throw PP.ArgumentNullException("Argument cannot be null", this);
}
};
// Transform degrees to radians
console.log("45° = " + this.toRadiant(45) + " rad");
console.log("60° = " + this.toRadiant(60) + " rad");
console.log("90° = " + this.toRadiant(90) + " rad");
After executing the example values of the 45°, 60° and 90° angles are converted to radians:
45° = 0.7853981633974483 rad
60° = 1.0471975511965976 rad
90° = 1.5707963267948966 rad
See also: