agentscape
Version:
Agentscape is a library for creating agent-based simulations. It provides a simple API for defining agents and their behavior, and for defining the environment in which the agents interact. Agentscape is designed to be flexible and extensible, allowing
35 lines (34 loc) • 1.18 kB
TypeScript
import Angle from './Angle';
import RandomGenerator from './RandomGenerator';
export type Tuple = [number, number];
export default class Vector2 {
components: Tuple;
static random(rng: RandomGenerator, min: number, max: number): Vector2;
static randomInt(rng: RandomGenerator, min: number, max: number): Vector2;
constructor(components: Tuple);
get x(): number;
get y(): number;
set x(value: number);
set y(value: number);
get magnitude(): number;
get normal(): Vector2;
get angle(): Angle;
dot(other: Vector2): number;
add(other: Vector2): Vector2;
subtract(other: Vector2): Vector2;
subtractScalar(scalar: number): Vector2;
divideScalar(scalar: number): Vector2;
divide(other: Vector2): Vector2;
scale(scalar: number): Vector2;
lerp(other: Vector2, alpha: number): Vector2;
rotate(angle: number): Vector2;
clamp(min: number, max: number): Vector2;
/**
* Computes the Euclidean distance to an other vector
*/
euclideanDistance(other: this): number;
/**
* Computes the Euclidean distance to an other vector
*/
euclideanDistanceSqr(other: this): number;
}