MCPcopy Create free account
hub / github.com/microsoft/SandDance / MathArray

Class MathArray

docs/app/js/sanddance-app.js:69252–69377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69250 return ExtendableBuiltin;
69251}
69252class MathArray extends _extendableBuiltin(Array) {
69253 clone() {
69254 return new this.constructor().copy(this);
69255 }
69256 fromArray(array, offset = 0) {
69257 for(let i = 0; i < this.ELEMENTS; ++i)this[i] = array[i + offset];
69258 return this.check();
69259 }
69260 toArray(targetArray = [], offset = 0) {
69261 for(let i = 0; i < this.ELEMENTS; ++i)targetArray[offset + i] = this[i];
69262 return targetArray;
69263 }
69264 from(arrayOrObject) {
69265 return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
69266 }
69267 to(arrayOrObject) {
69268 if (arrayOrObject === this) return this;
69269 return (0, _common.isArray)(arrayOrObject) ? this.toArray(arrayOrObject) : this.toObject(arrayOrObject);
69270 }
69271 toTarget(target) {
69272 return target ? this.to(target) : this;
69273 }
69274 toFloat32Array() {
69275 return new Float32Array(this);
69276 }
69277 toString() {
69278 return this.formatString((0, _common.config));
69279 }
69280 formatString(opts) {
69281 let string = "";
69282 for(let i = 0; i < this.ELEMENTS; ++i)string += (i > 0 ? ", " : "") + (0, _common.formatValue)(this[i], opts);
69283 return "".concat(opts.printTypes ? this.constructor.name : "", "[").concat(string, "]");
69284 }
69285 equals(array) {
69286 if (!array || this.length !== array.length) return false;
69287 for(let i = 0; i < this.ELEMENTS; ++i){
69288 if (!(0, _common.equals)(this[i], array[i])) return false;
69289 }
69290 return true;
69291 }
69292 exactEquals(array) {
69293 if (!array || this.length !== array.length) return false;
69294 for(let i = 0; i < this.ELEMENTS; ++i){
69295 if (this[i] !== array[i]) return false;
69296 }
69297 return true;
69298 }
69299 negate() {
69300 for(let i = 0; i < this.ELEMENTS; ++i)this[i] = -this[i];
69301 return this.check();
69302 }
69303 lerp(a, b, t) {
69304 if (t === undefined) return this.lerp(this, a, b);
69305 for(let i = 0; i < this.ELEMENTS; ++i){
69306 const ai = a[i];
69307 this[i] = ai + t * (b[i] - ai);
69308 }
69309 return this.check();

Callers

nothing calls this directly

Calls 1

_extendableBuiltinFunction · 0.70

Tested by

no test coverage detected