common.js.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: common.js</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Source: common.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>/**
  20. * Common utilities
  21. * @module glMatrix
  22. */
  23. // Configuration Constants
  24. export const EPSILON = 0.000001;
  25. export let ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array;
  26. export const RANDOM = Math.random;
  27. /**
  28. * Sets the type of array used when creating new vectors and matrices
  29. *
  30. * @param {Type} type Array type, such as Float32Array or Array
  31. */
  32. export function setMatrixArrayType(type) {
  33. ARRAY_TYPE = type;
  34. }
  35. const degree = Math.PI / 180;
  36. /**
  37. * Convert Degree To Radian
  38. *
  39. * @param {Number} a Angle in Degrees
  40. */
  41. export function toRadian(a) {
  42. return a * degree;
  43. }
  44. /**
  45. * Tests whether or not the arguments have approximately the same value, within an absolute
  46. * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
  47. * than or equal to 1.0, and a relative tolerance is used for larger values)
  48. *
  49. * @param {Number} a The first number to test.
  50. * @param {Number} b The second number to test.
  51. * @returns {Boolean} True if the numbers are approximately equal, false otherwise.
  52. */
  53. export function equals(a, b) {
  54. return Math.abs(a - b) &lt;= EPSILON*Math.max(1.0, Math.abs(a), Math.abs(b));
  55. }
  56. </code></pre>
  57. </article>
  58. </section>
  59. </div>
  60. <nav>
  61. <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-glMatrix.html">glMatrix</a></li><li><a href="module-mat2.html">mat2</a></li><li><a href="module-mat2d.html">mat2d</a></li><li><a href="module-mat3.html">mat3</a></li><li><a href="module-mat4.html">mat4</a></li><li><a href="module-quat.html">quat</a></li><li><a href="module-quat2.html">quat2</a></li><li><a href="module-vec2.html">vec2</a></li><li><a href="module-vec3.html">vec3</a></li><li><a href="module-vec4.html">vec4</a></li></ul>
  62. </nav>
  63. <br class="clear">
  64. <footer>
  65. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Jul 13 2018 11:51:33 GMT+0200 (W. Europe Daylight Time)
  66. </footer>
  67. <script> prettyPrint(); </script>
  68. <script src="scripts/linenumber.js"> </script>
  69. </body>
  70. </html>