"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Vector2 = void 0;
var Vector2 = /** @class */ (function () {
    function Vector2(x, y) {
        this.x = x;
        this.y = y;
    }
    Vector2.lerp = function (a, b, t) {
        return a.multiplyScalar(1 - t).add(b.multiplyScalar(t));
    };
    Vector2.prototype.add = function (vector) {
        return new Vector2(this.x + vector.x, this.y + vector.y);
    };
    Vector2.prototype.subtract = function (vector) {
        return new Vector2(this.x - vector.x, this.y - vector.y);
    };
    Vector2.prototype.multiplyScalar = function (scalar) {
        return new Vector2(this.x * scalar, this.y * scalar);
    };
    Vector2.prototype.dot = function (vector) {
        return this.x * vector.x + this.y * vector.y;
    };
    Vector2.prototype.cross = function (vector) {
        return this.x * vector.y - this.y * vector.x;
    };
    Vector2.prototype.magnitude = function () {
        return Math.sqrt(this.x * this.x + this.y * this.y);
    };
    Vector2.prototype.normalized = function () {
        var magnitude = this.magnitude();
        if (magnitude === 0) {
            throw new Error("Cannot normalize a vector with magnitude 0");
        }
        return this.multiplyScalar(1 / magnitude);
    };
    Vector2.prototype.distance = function (vector) {
        return Math.sqrt(Math.pow((this.x - vector.x), 2) + Math.pow((this.y - vector.y), 2));
    };
    Vector2.prototype.distanceSquared = function (vector) {
        return Math.pow((this.x - vector.x), 2) + Math.pow((this.y - vector.y), 2);
    };
    Vector2.prototype.limit = function (max) {
        var magnitude = this.magnitude();
        if (magnitude > max) {
            return this.normalized().multiplyScalar(max);
        }
        return this;
    };
    Vector2.prototype.angle = function () {
        return Math.atan2(this.y, this.x);
    };
    Vector2.prototype.angleBetween = function (vector) {
        var dotProd = this.dot(vector);
        var magnitudes = this.magnitude() * vector.magnitude();
        if (magnitudes === 0) {
            throw new Error("Cannot calculate angle with a zero-magnitude vector");
        }
        return Math.acos(dotProd / magnitudes);
    };
    Vector2.prototype.clone = function () {
        return new Vector2(this.x, this.y);
    };
    Vector2.prototype.equals = function (vector) {
        return this.x === vector.x && this.y === vector.y;
    };
    Vector2.prototype.rotate = function (angle) {
        var cos = Math.cos(angle);
        var sin = Math.sin(angle);
        return new Vector2(this.x * cos - this.y * sin, this.x * sin + this.y * cos);
    };
    return Vector2;
}());
exports.Vector2 = Vector2;
