Skip to content

Instantly share code, notes, and snippets.

@Rich-Harris
Created May 18, 2017 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rich-Harris/7861d982561a4d1457171ed783cde49c to your computer and use it in GitHub Desktop.
Save Rich-Harris/7861d982561a4d1457171ed783cde49c to your computer and use it in GitHub Desktop.
function _Calc() {
}
_Calc.prototype._ = function () {
return new _Calc();
};
_Calc.prototype.Sign = function (x) {
return typeof x === "number" ? x ? x < 0 ? -1 : 1 : x === x ? 0 : NaN : NaN;
};
_Calc.prototype.RotationDeg = function (rotation) {
var rot = (rotation * _Calc.ROTATION_DEGREE_PRECISION) | 0;
while (rot < 0) {
rot += _Calc.DEG360;
}
while (rot >= _Calc.DEG360) {
rot -= _Calc.DEG360;
}
return _Calc.ROTATION_LOOKUP[rot];
};
_Calc.prototype.RotationRad = function (rotation) {
var rot = rotation * _Calc.DEGREE_FACTOR * _Calc.ROTATION_DEGREE_PRECISION | 0;
return this.RotationDeg(rot / _Calc.ROTATION_DEGREE_PRECISION);
};
_Calc.prototype.ClosestRadianRotation = function (rotation) {
var rot = rotation * _Calc.DEGREE_FACTOR * _Calc.ROTATION_DEGREE_PRECISION | 0;
while (rot < 0) {
rot += _Calc.DEG360;
}
while (rot >= _Calc.DEG360) {
rot -= _Calc.DEG360;
}
return rot * _Calc.RADIAN_FACTOR / _Calc.ROTATION_DEGREE_PRECISION;
};
_Calc.ROTATION_DEGREE_PRECISION = 1;
_Calc.RADIAN_FACTOR = (1 / 360) * (2 * Math.PI);
_Calc.DEGREE_FACTOR = (1 / (2 * Math.PI) * 360);
_Calc.DEG360 = 360 * _Calc.ROTATION_DEGREE_PRECISION;
//_Calc.ROTATION_LOOKUP = (function () {
// var lookup = [];
// for (var i = 0; i < 360 * _Calc.ROTATION_DEGREE_PRECISION; i++) {
// lookup.push([Math.cos(i * _Calc.RADIAN_FACTOR), Math.sin(i * _Calc.RADIAN_FACTOR)]);
// }
// return lookup;
//})();
//var Calc = new _Calc();
export { _Calc as Calc };
//# sourceMappingURL=goodcore.es.js.map
import { Calc } from './goodcore.js';
// console.log( new Calc() );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment