export class Vector4 { constructor( public x: number = 0, public y: number = 0, public z: number = 0, public w: number = 0 ) {} static fromArray(arr: number[]): Vector4 { return new Vector4(arr[0], arr[1], arr[2], arr[3]); } toArray(): [number, number, number, number] { return [this.x, this.y, this.z, this.w]; } add(other: Vector4): Vector4 { return new Vector4(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w); } subtract(other: Vector4): Vector4 { return new Vector4(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w); } multiply(scalar: number): Vector4 { return new Vector4(this.x * scalar, this.y * scalar, this.z * scalar, this.w * scalar); } length(): number { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); } normalize(): Vector4 { const len = this.length(); if (len === 0) return new Vector4(); return this.multiply(1 / len); } distance(other: Vector4): number { return this.subtract(other).length(); } }