@game-vir/entity
Version:
Entity system for game development.
61 lines (60 loc) • 2.15 kB
TypeScript
import { type Coords } from '@augment-vir/common';
import { Angle } from './angle.js';
/**
* A vector (combination of magnitude and angle) definition. This can be defined in the following
* ways:
*
* - `Vector.fromPoints()`
* - `Vector.fromComponents()`
* - `new Vector()`
*
* @category Math
*/
export declare class Vector {
/** The vector's original angle. (This can be modified after Vector construction.) */
angle: Angle;
/** Vector options. Set to `undefined` to disable all options. */
readonly options: {
/**
* Number of digits to round all values to. Set to `undefined` to disable
* rounding.
*/
digits: number | undefined;
} | undefined;
/** Create a new Vector instance by calculating the distance and angle between two points. */
static fromPoints(point1: Coords, point2: Coords, options: {
/**
* Number of digits to round all values to. Set to `undefined` to disable
* rounding.
*/
digits: number | undefined;
} | undefined): Vector;
/** Create a new Vector instance from its X and Y components. */
static fromComponents({ x, y }: Coords, options: {
/**
* Number of digits to round all values to. Set to `undefined` to disable
* rounding.
*/
digits: number | undefined;
} | undefined): Vector;
/** The vector's distance in its given angle. (This can be modified after Vector construction.) */
magnitude: number;
constructor(
/** The vector's original magnitude. (This can be modified after Vector construction.) */
magnitude: number,
/** The vector's original angle. (This can be modified after Vector construction.) */
angle: Angle,
/** Vector options. Set to `undefined` to disable all options. */
options: {
/**
* Number of digits to round all values to. Set to `undefined` to disable
* rounding.
*/
digits: number | undefined;
} | undefined);
/** Splits the vector into its X and Y components. */
toComponents(): {
x: number;
y: number;
};
}