vec.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. /**
  20. * On platforms that don't have native Float32Array or Float64Array support we
  21. * use a javascript implementation so that this math library can be used on all
  22. * platforms.
  23. */
  24. goog.require('goog.vec.Float32Array');
  25. goog.require('goog.vec.Float64Array');
  26. // All vector and matrix operations are based upon arrays of numbers using
  27. // either Float32Array, Float64Array, or a standard Javascript Array of
  28. // Numbers.
  29. /** @typedef {Float32Array} */
  30. goog.vec.Float32;
  31. /** @typedef {Float64Array} */
  32. goog.vec.Float64;
  33. /** @typedef {Array.<number>} */
  34. goog.vec.Number;
  35. /** @typedef {goog.vec.Float32|goog.vec.Float64|goog.vec.Number} */
  36. goog.vec.AnyType;
  37. /**
  38. * @deprecated Use AnyType.
  39. * @typedef {Float32Array|Array.<number>}
  40. */
  41. goog.vec.ArrayType;
  42. /**
  43. * For graphics work, 6 decimal places of accuracy are typically all that is
  44. * required.
  45. *
  46. * @type {number}
  47. * @const
  48. */
  49. goog.vec.EPSILON = 1e-6;