| 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 |
|
| 16 |
/** |
| 17 |
* @fileoverview Supplies global data types and constants for the vector math |
| 18 |
* library. |
| 19 |
*/ |
| 20 |
goog.provide('goog.vec'); |
| 21 |
goog.provide('goog.vec.AnyType'); |
| 22 |
goog.provide('goog.vec.ArrayType'); |
| 23 |
goog.provide('goog.vec.Float32'); |
| 24 |
goog.provide('goog.vec.Float64'); |
| 25 |
goog.provide('goog.vec.Number'); |
| 26 |
|
| 27 |
|
| 28 |
/** |
| 29 |
* On platforms that don't have native Float32Array or Float64Array support we |
| 30 |
* use a javascript implementation so that this math library can be used on all |
| 31 |
* platforms. |
| 32 |
* @suppress {extraRequire} |
| 33 |
*/ |
| 34 |
goog.require('goog.vec.Float32Array'); |
| 35 |
/** @suppress {extraRequire} */ |
| 36 |
goog.require('goog.vec.Float64Array'); |
| 37 |
|
| 38 |
// All vector and matrix operations are based upon arrays of numbers using |
| 39 |
// either Float32Array, Float64Array, or a standard Javascript Array of |
| 40 |
// Numbers. |
| 41 |
|
| 42 |
|
| 43 |
/** @typedef {!Float32Array} */ |
| 44 |
goog.vec.Float32; |
| 45 |
|
| 46 |
|
| 47 |
/** @typedef {!Float64Array} */ |
| 48 |
goog.vec.Float64; |
| 49 |
|
| 50 |
|
| 51 |
/** @typedef {!Array<number>} */ |
| 52 |
goog.vec.Number; |
| 53 |
|
| 54 |
|
| 55 |
/** @typedef {!goog.vec.Float32|!goog.vec.Float64|!goog.vec.Number} */ |
| 56 |
goog.vec.AnyType; |
| 57 |
|
| 58 |
|
| 59 |
/** |
| 60 |
* @deprecated Use AnyType. |
| 61 |
* @typedef {!Float32Array|!Array<number>} |
| 62 |
*/ |
| 63 |
goog.vec.ArrayType; |
| 64 |
|
| 65 |
|
| 66 |
/** |
| 67 |
* For graphics work, 6 decimal places of accuracy are typically all that is |
| 68 |
* required. |
| 69 |
* |
| 70 |
* @type {number} |
| 71 |
* @const |
| 72 |
*/ |
| 73 |
goog.vec.EPSILON = 1e-6; |