graphic-pixi/lib/math/Vector2.d.ts
2023-12-14 13:07:43 +08:00

92 lines
2.4 KiB
TypeScript

export default class Vector2 {
constructor(values?: [number, number]);
static from(p: {
x: number;
y: number;
}): Vector2;
private values;
static readonly zero: Vector2;
static readonly one: Vector2;
get x(): number;
set x(value: number);
get y(): number;
set y(value: number);
get xy(): [number, number];
set xy(values: [number, number]);
at(index: number): number;
reset(): void;
copy(dest?: Vector2): Vector2;
negate(dest?: Vector2): Vector2;
equals(vector: Vector2, threshold?: number): boolean;
length(): number;
squaredLength(): number;
add(vector: Vector2): Vector2;
subtract(vector: Vector2): Vector2;
multiply(vector: Vector2): Vector2;
divide(vector: Vector2): Vector2;
scale(value: number, dest?: Vector2): Vector2;
normalize(dest?: Vector2): Vector2;
/**
* 向量点乘
* @param vector
* @param vector2
* @returns
*/
static dot(vector: Vector2, vector2: Vector2): number;
/**
* 向量长度
* @param vector
* @param vector2
* @returns
*/
static distance(vector: Vector2, vector2: Vector2): number;
/**
* 向量长度平方
* @param vector
* @param vector2
* @returns
*/
static squaredDistance(vector: Vector2, vector2: Vector2): number;
/**
* v2->v1的方向的单位向量
* @param v1
* @param v2
* @param dest
* @returns
*/
static direction(v1: Vector2, v2: Vector2, dest?: Vector2): Vector2;
static mix(vector: Vector2, vector2: Vector2, time: number, dest?: Vector2): Vector2;
/**
* 向量加法
* @param vector
* @param vector2
* @param dest
* @returns
*/
static sum(vector: Vector2, vector2: Vector2, dest?: Vector2): Vector2;
/**
* 向量减法
* @param vector
* @param vector2
* @param dest
* @returns
*/
static difference(vector: Vector2, vector2: Vector2, dest?: Vector2): Vector2;
/**
* 向量乘法
* @param vector
* @param vector2
* @param dest
* @returns
*/
static product(vector: Vector2, vector2: Vector2, dest?: Vector2): Vector2;
/**
* 向量除法
* @param vector
* @param vector2
* @param dest
* @returns
*/
static quotient(vector: Vector2, vector2: Vector2, dest?: Vector2): Vector2;
}