vec.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2011 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview Supplies global data types and constants for the vector math
  16. * library.
  17. */
  18. goog.provide('goog.vec');
  19. goog.provide('goog.vec.AnyType');
  20. goog.provide('goog.vec.ArrayType');
  21. goog.provide('goog.vec.Float32');
  22. goog.provide('goog.vec.Float64');
  23. goog.provide('goog.vec.Number');
  24. /**
  25. * On platforms that don't have native Float32Array or Float64Array support we
  26. * use a javascript implementation so that this math library can be used on all
  27. * platforms.
  28. * @suppress {extraRequire}
  29. */
  30. goog.require('goog.vec.Float32Array');
  31. /** @suppress {extraRequire} */
  32. goog.require('goog.vec.Float64Array');
  33. // All vector and matrix operations are based upon arrays of numbers using
  34. // either Float32Array, Float64Array, or a standard JavaScript Array of
  35. // Numbers.
  36. /** @typedef {!Float32Array} */
  37. goog.vec.Float32;
  38. /** @typedef {!Float64Array} */
  39. goog.vec.Float64;
  40. /** @typedef {!Array<number>} */
  41. goog.vec.Number;
  42. /** @typedef {!goog.vec.Float32|!goog.vec.Float64|!goog.vec.Number} */
  43. goog.vec.AnyType;
  44. /**
  45. * @deprecated Use AnyType.
  46. * @typedef {!Float32Array|!Array<number>}
  47. */
  48. goog.vec.ArrayType;
  49. /**
  50. * For graphics work, 6 decimal places of accuracy are typically all that is
  51. * required.
  52. *
  53. * @type {number}
  54. * @const
  55. */
  56. goog.vec.EPSILON = 1e-6;