malwoden
Version:
   
38 lines (37 loc) • 1.53 kB
TypeScript
import { Vector2 } from "../struct/vector";
/** Contains math for common vector operations. */
export declare class Vector {
/**
* Returns true if two vectors have the same x and y values.
* @param v1 The first Vector2.
* @param v2 The second Vector2.
*/
static areEqual(v1: Vector2, v2: Vector2): boolean;
/**
* Returns the distance between two vectors.
*
* If no topology is given, diagonal distance is sqrt(2).
* If topology is four, diagonal distance is 2.
* If topology is eight, diagonal distance is 1.
*
* @param start The starting Vector2.
* @param end The ending Vector2.
* @param topology Can use "four" or "eight" for non-cartesian distances.
*/
static getDistance(start: Vector2, end: Vector2, topology?: "four" | "eight"): number;
/**
* Will find the center of an area by averaging all Vectors in the area.
* This point may not be in the area itself, for example in a donut shaped area.
* @param area Vector2
*/
static getCenter(area: Vector2[]): Vector2;
/**
* Will find the position in the area closest to the target
* @param area Vector2[]
* @param target Vector2
* @param topology Either 'four' or 'eight'. Default 'four'
*/
static getClosest(area: Vector2[], target: Vector2, topology?: "four" | "eight"): Vector2;
static add(v1: Vector2, v2: Vector2): Vector2;
static subtract(v1: Vector2, v2: Vector2): Vector2;
}