vec.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * @license
  3. * Copyright The Closure Library Authors.
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @fileoverview Supplies global data types and constants for the vector math
  8. * library.
  9. */
  10. goog.provide('goog.vec');
  11. goog.provide('goog.vec.AnyType');
  12. goog.provide('goog.vec.ArrayType');
  13. goog.provide('goog.vec.Float32');
  14. goog.provide('goog.vec.Float64');
  15. goog.provide('goog.vec.Number');
  16. /**
  17. * On platforms that don't have native Float32Array or Float64Array support we
  18. * use a javascript implementation so that this math library can be used on all
  19. * platforms.
  20. * @suppress {extraRequire}
  21. */
  22. goog.require('goog.vec.Float32Array');
  23. /** @suppress {extraRequire} */
  24. goog.require('goog.vec.Float64Array');
  25. // All vector and matrix operations are based upon arrays of numbers using
  26. // either Float32Array, Float64Array, or a standard JavaScript Array of
  27. // Numbers.
  28. /** @typedef {!Float32Array} */
  29. goog.vec.Float32;
  30. /** @typedef {!Float64Array} */
  31. goog.vec.Float64;
  32. /** @typedef {!Array<number>} */
  33. goog.vec.Number;
  34. /** @typedef {!goog.vec.Float32|!goog.vec.Float64|!goog.vec.Number} */
  35. goog.vec.AnyType;
  36. /**
  37. * @deprecated Use AnyType.
  38. * @typedef {!Float32Array|!Array<number>}
  39. */
  40. goog.vec.ArrayType;
  41. /**
  42. * For graphics work, 6 decimal places of accuracy are typically all that is
  43. * required.
  44. *
  45. * @type {number}
  46. * @const
  47. */
  48. goog.vec.EPSILON = 1e-6;