phpjs
Version:
54 lines (44 loc) • 1.66 kB
Markdown
layout: page
title: "JavaScript deg2rad function"
comments: true
sharing: true
footer: true
alias:
- /functions/view/deg2rad:386
- /functions/view/deg2rad
- /functions/view/386
- /functions/deg2rad:386
- /functions/386
<!-- Generated by Rakefile:build -->
A JavaScript equivalent of PHP's deg2rad
{% codeblock math/deg2rad.js lang:js https://raw.github.com/kvz/phpjs/master/functions/math/deg2rad.js raw on github %}
function deg2rad (angle) {
// From: http://phpjs.org/functions
// + original by: Enrique Gonzalez
// + improved by: Thomas Grainger (http://graingert.co.uk)
// * example 1: deg2rad(45);
// * returns 1: 0.7853981633974483
return angle * .017453292519943295; // (angle / 180) * Math.PI;
}
{% endcodeblock %}
- [Raw function on GitHub](https://github.com/kvz/phpjs/blob/master/functions/math/deg2rad.js)
Please note that php.js uses JavaScript objects as substitutes for PHP arrays, they are
the closest match to this hashtable-like data structure.
Please also note that php.js offers community built functions and goes by the
[McDonald's Theory](https://medium.com/what-i-learned-building/9216e1c9da7d). We'll put online
functions that are far from perfect, in the hopes to spark better contributions.
Do you have one? Then please just:
- [Edit on GitHub](https://github.com/kvz/phpjs/edit/master/functions/math/deg2rad.js)
### Example 1
This code
{% codeblock lang:js example %}
deg2rad(45);
{% endcodeblock %}
Should return
{% codeblock lang:js returns %}
0.7853981633974483
{% endcodeblock %}
### Other PHP functions in the math extension
{% render_partial _includes/custom/math.html %}