UNPKG

cornerstone-math

Version:

Math and computation geometry functionality for cornerstone

107 lines (76 loc) 2.75 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>math.js - Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Line3.html">Line3</a></li><li><a href="Plane.html">Plane</a></li></ul><h3>Global</h3><ul><li><a href="global.html#approximatelyEquals">approximatelyEquals</a></li><li><a href="global.html#findClosestPoint">findClosestPoint</a></li></ul> </nav> <div id="main"> <h1 class="page-title">math.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>const EPSILON = 0.0001; // Based on THREE.JS function clamp (x, a, b) { return (x &lt; a) ? a : ((x > b) ? b : x); } function degToRad (degrees) { const degreeToRadiansFactor = Math.PI / 180; return degrees * degreeToRadiansFactor; } function radToDeg (radians) { const radianToDegreesFactor = 180 / Math.PI; return radians * radianToDegreesFactor; } // Returns sign of number function sign (x) { return typeof x === 'number' ? x ? x &lt; 0 ? -1 : 1 : x === x ? 0 : NaN : NaN; } /** * * Compare if two numbers are equal(if they have approximately the same value). to prevent js float precision issue * Adapted from glmatrix * @param {number} a * @param {number} b * @param {number} epsilon Precision to define proximity * @return {boolean} check whether or not the arguments have approximately the same value * */ function approximatelyEquals (a, b, epsilon) { const _epsilon = epsilon || EPSILON; return Math.abs(a - b) &lt;= _epsilon*Math.max(1.0, Math.abs(a), Math.abs(b)); } export { clamp, degToRad, approximatelyEquals, radToDeg, sign }; </code></pre> </article> </section> </div> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.6</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. </footer> <script>prettyPrint();</script> <script src="scripts/linenumber.js"></script> </body> </html>