/**
 * Copyright(c) Live2D Inc. All rights reserved.
 *
 * Use of this source code is governed by the Live2D Open Software license
 * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
 */ /**
 * 2次元ベクトル型
 *
 * 2次元ベクトル型の機能を提供する。
 */ export class CubismVector2 { /**
     * コンストラクタ
     */ public constructor ( public x ? , public y ? ) { this . x = x == undefined ? 0.0 : x ; this . y = y == undefined ? 0.0 : y ; } param vector2 return public add ( vector2 ) { const ret = new CubismVector2 ( 0.0 , 0.0 ) ; ret . x = this . x + vector2 . x ; ret . y = this . y + vector2 . y ; return ret ; } param vector2 return public substract ( vector2 ) { const ret = new CubismVector2 ( 0.0 , 0.0 ) ; ret . x = this . x - vector2 . x ; ret . y = this . y - vector2 . y ; return ret ; } param vector2 return public multiply ( vector2 ) { const ret = new CubismVector2 ( 0.0 , 0.0 ) ; ret . x = this . x * vector2 . x ; ret . y = this . y * vector2 . y ; return ret ; } param scalar return public multiplyByScaler ( scalar ) { return this . multiply ( new CubismVector2 ( scalar , scalar ) ) ; } param vector2 return public division ( vector2 ) { const ret = new CubismVector2 ( 0.0 , 0.0 ) ; ret . x = this . x / vector2 . x ; ret . y = this . y / vector2 . y ; return ret ; } param scalar return public divisionByScalar ( scalar ) { return this . division ( new CubismVector2 ( scalar , scalar ) ) ; } return public getLength ( ) { return Math . sqrt ( this . x * this . x + this . y * this . y ) ; } param a return public getDistanceWith ( a ) { return Math . sqrt ( ( this . x - a . x ) * ( this . x - a . x ) + ( this . y - a . y ) * ( this . y - a . y ) ) ; } param a return public dot ( a ) { return this . x * a . x + this . y * a . y ; } /**
     * 正規化の適用
     */ public normalize ( ) { const length = Math . pow ( this . x * this . x + this . y * this . y , 0.5 ) ; this . x = this . x / length ; this . y = this . y / length ; } param rhs return return public isEqual ( rhs ) { return this . x == rhs . x && this . y == rhs . y ; } param rhs return return public isNotEqual ( rhs ) { return ! this . isEqual ( rhs ) ; } } import * as $ from './cubismvector2' ; export namespace Live2DCubismFramework { export const CubismVector2 = $ . CubismVector2 ; export type CubismVector2 = $ . CubismVector2 ; }