misc.ts 441 B

1234567891011121314151617
  1. /**
  2. * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. export function degToRad (deg: number) {
  7. return deg * 0.01745 // deg * Math.PI / 180
  8. }
  9. export function radToDeg (rad: number) {
  10. return rad * 57.29578 // rad * 180 / Math.PI
  11. }
  12. export function isPowerOfTwo (x: number) {
  13. return (x !== 0) && (x & (x - 1)) === 0
  14. }