import { degToRad, radToDeg } from './utils';
import WBVector from './wbVector';
export default class WBVectorXZ extends WBVector {
    constructor(x, z) {
        super();
        this.x = x;
        this.z = z;
    }
    static fromMC(vec2) {
        return new WBVectorXZ(vec2.x, vec2.z);
    }
    add(other) {
        return new WBVectorXZ(this.x + other.x, this.z + other.z);
    }
    subtract(other) {
        return new WBVectorXZ(this.x - other.x, this.z - other.z);
    }
    transform(transformFn) {
        return new WBVectorXZ(transformFn(this.x), transformFn(this.z));
    }
    multiply(value) {
        return new WBVectorXZ(this.x * value, this.z * value);
    }
    divide(value) {
        return new WBVectorXZ(this.x / value, this.z / value);
    }
    length() {
        return Math.sqrt(this.x ** 2 + this.z ** 2);
    }
    normalize() {
        const length = this.length();
        return new WBVectorXZ(this.x / length, this.z / length);
    }
    dot(other) {
        return this.x * other.x + this.z * other.z;
    }
    rotate(degrees) {
        const angle = degToRad(degrees);
        return new WBVectorXZ(this.x * Math.cos(angle) - this.z * Math.sin(angle), this.x * Math.sin(angle) + this.z * Math.cos(angle));
    }
    angle() {
        return radToDeg(Math.acos(this.x / Math.sqrt(this.x * this.x + this.z * this.z))
            * (this.z / Math.abs(this.z)));
    }
    roundAll() {
        return new WBVectorXZ(Math.round(this.x), Math.round(this.z));
    }
    floorAll() {
        return new WBVectorXZ(Math.floor(this.x), Math.floor(this.z));
    }
    ceilAll() {
        return new WBVectorXZ(Math.ceil(this.x), Math.ceil(this.z));
    }
    abs() {
        return new WBVectorXZ(Math.abs(this.x), Math.abs(this.z));
    }
    equals(other) {
        return this.x === other.x && this.z === other.z;
    }
    toString() {
        return `VecXZ(${this.x}, ${this.z})`;
    }
    toTuple() {
        return [this.x, this.z];
    }
    *[Symbol.iterator]() {
        yield this.x;
        yield this.z;
    }
}
