All files / src/extensions extensionsVector2.js

100% Statements 17/17
100% Branches 4/4
100% Functions 4/4
100% Lines 17/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  1x 1x 1x 1x 1x   1x 3x     1x 2x 2x 2x 1x 2x 1x 2x   1x 1x    
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vector2_1 = require("../models/vector2");
vector2_1.Vector2.prototype.set = function (vector) {
    this.x = vector.x;
    this.y = vector.y;
};
vector2_1.Vector2.prototype.getLength = function () {
    return Math.sqrt((this.x * this.x) +
        (this.y * this.y));
};
vector2_1.Vector2.prototype.getNormalize = function () {
    const length = this.getLength();
    const nomalized = new vector2_1.Vector2();
    if (this.x != 0)
        nomalized.x = this.x / length;
    if (this.y != 0)
        nomalized.y = this.y / length;
    return nomalized;
};
vector2_1.Vector2.prototype.getScalar = function (vector) {
    return this.x * vector.x + this.y * vector.y;
};