import { AffineTransform } from "./AffineTransform" ; /**
 * Minimal interface of a 2D vector.
 */ export interface Vector2Like { x : number ; y : number ; } export interface ReadonlyVector2Like { readonly x : number ; readonly y : number ; } export interface ReadonlyVector2 extends ReadonlyVector2Like { return getLength ( ) : number ; return getSquareLength ( ) : number ; param v return getDistance ( v ) : number ; param v return getSquareDistance ( v ) : number ; param v return dot ( v ) : number ; param maxFractionDigits return toString ( maxFractionDigits ? ) : string ; } /**
 * Vector with two floating point components.
 */ export class Vector2 implements ReadonlyVector2Like , Vector2Like { /**
     * Creates a new vector with all components set to 0.
     */ public constructor ( ) ; param x param y public constructor ( x , y ) ; public constructor ( public x = 0 , public y = 0 ) { } inheritDoc public toString ( ) { return `[ ${ this . x }, ${ this . y } ]` ; } param x param y public setComponents ( x , y ) { this . x = x ; this . y = y ; return this ; } param vector public setVector ( vector ) { this . x = vector . x ; this . y = vector . y ; return this ; } inheritDoc public clone ( ) { return new Vector2 ( this . x , this . y ) ; } inheritDoc public getSquareLength ( ) { return this . x ** 2 + this . y ** 2 ; } inheritDoc public getLength ( ) { return Math . sqrt ( this . getSquareLength ( ) ) ; } inheritDoc public getSquareDistance ( v ) { return ( this . x - v . x ) ** 2 + ( this . y - v . y ) ** 2 ; } inheritDoc public getDistance ( v ) { return Math . sqrt ( this . getSquareDistance ( v ) ) ; } inheritDoc public dot ( v ) { return this . x * v . x + this . y * v . y ; } /**
     * Negates this vector.
     */ public negate ( ) { this . x = - this . x ; this . y = - this . y ; return this ; } /**
     * Resets all components of this vector to 0.
     */ public reset ( ) { this . x = this . y = 0 ; return this ; } param x param y public translate ( x , y ) { this . x += x ; this . y += y ; return this ; } param summand public add ( summand ) { this . x += summand . x ; this . y += summand . y ; return this ; } param subtrahend public sub ( subtrahend ) { this . x -= subtrahend . x ; this . y -= subtrahend . y ; return this ; } param matrix public mul ( arg ) { const x = this . x ; const y = this . y ; this . x = x * arg . m11 + y * arg . m21 + arg . dx ; this . y = x * arg . m12 + y * arg . m22 + arg . dy ; return this ; } param matrix public div ( arg ) { const b11 = arg . m11 , b12 = arg . m12 ; const b21 = arg . m21 , b22 = arg . m22 ; const x = this . x ; const y = this . y ; const d = b11 * b22 - b12 * b21 ; const c11 = b22 / d ; const c12 = - b12 / d ; const c21 = - b21 / d ; const c22 = b11 / d ; const b31 = arg . dx , b32 = arg . dy ; this . x = x * c11 + y * c21 + ( b21 * b32 - b31 * b22 ) / d ; this . y = x * c12 + y * c22 + ( b31 * b12 - b11 * b32 ) / d ; return this ; } /**
     * Normalizes this vector to a length of 1.
     */ public normalize ( ) { const len = this . getLength ( ) ; this . x /= len ; this . y /= len ; return this ; } }