@xtor/cga.js
Version:
Xtor Compute Geometry Algorithm Libary 计算几何算法库
67 lines (66 loc) • 2.24 kB
TypeScript
import { Mat3 } from './Mat3';
import { EventHandler } from '../render/eventhandler';
export declare class Vec2 extends EventHandler {
private _x;
private _y;
isVec2: boolean;
x: number;
y: number;
constructor(_x?: number, _y?: number);
static isVec2(v: any): boolean;
get width(): number;
set width(value: number);
get height(): number;
set height(value: number);
static get UnitX(): Vec2;
static get UnitY(): Vec2;
set(x: number, y: number): this;
setScalar(scalar: number): this;
setX(x: number): this;
setY(y: number): this;
setComponent(index: number, value: number): this;
getComponent(index: number): number;
clone(): Vec2;
copy(v: Vec2): Vec2;
add(v: Vec2, w?: Vec2): this;
addScalar(s: number): this;
addVecs(a: Vec2, b: Vec2): this;
addScaledVec(v: Vec2, s: number): this;
sub(v: Vec2, w: Vec2): this;
subScalar(s: number): this;
subVecs(a: Vec2, b: Vec2): this;
multiply(v: Vec2): this;
multiplyScalar(scalar: number): this;
divide(v: Vec2): this;
divideScalar(scalar: number): this;
applyMat3(m: Mat3): this;
min(v: Vec2): this;
max(v: Vec2): this;
clamp(min: Vec2, max: Vec2): this;
clampScalar(minVal: number, maxVal: number): this;
clampLength(min: number, max: number): this;
floor(): this;
ceil(): this;
round(): this;
roundToZero(): this;
negate(): this;
dot(v: Vec2): number;
cross(v: Vec2): number;
lengthSq(): number;
length(): number;
manhattanLength(): number;
normalize(): this;
angle(): number;
distanceTo(v: Vec2): number;
distanceToSquared(v: Vec2): number;
manhattanDistanceTo(v: Vec2): number;
setLength(length: number): this;
lerp(v: Vec2, alpha: number): this;
lerpVecs(v1: Vec2, v2: Vec2, alpha: number): this;
equals(v: Vec2): boolean;
fromArray(array: number[], offset?: number): this;
toArray(array?: number[], offset?: number): number[];
fromBufferAttribute(attribute: any, index: number, offset: any): this;
rotateAround(center: Vec2, angle: number): this;
}
export declare function v2(): Vec2;