@osbjs/osbjs
Version:
a minimalist osu! storyboarding framework
123 lines (122 loc) • 4.06 kB
TypeScript
import { Quaternion } from '.';
import { Matrix3 } from './Matrix3';
import { Matrix4 } from './Matrix4';
export declare class Vector2 {
x: number;
y: number;
static One: Vector2;
static UnitX: Vector2;
static UnitY: Vector2;
static Zero: Vector2;
constructor(x?: number, y?: number);
/**
* Returns true if the components of this vector and v are strictly equal; false otherwise.
*/
equals(v: Vector2): boolean;
/**
* Returns a new Vector2 with the same x, y values as this one.
*/
clone(): Vector2;
/**
* Returns the length of the vector.
*/
length(): number;
/**
* Returns the length of the vector squared.
*/
lengthSqr(): number;
/**
* Computes the Euclidean distance squared between the two given points.
*/
distanceToSqr(v: Vector2): number;
/**
* Computes the Euclidean distance between the two given points.
*/
distanceTo(v: Vector2): number;
/**
* Computes the angle in radians with respect to the positive x-axis.
*/
angle(): number;
/**
* Adds two vectors together.
*/
static add(v1: Vector2, v2: Vector2): Vector2;
/**
* Subtracts the second vector from the first.
*/
static sub(v1: Vector2, v2: Vector2): Vector2;
/**
* Returns a new vector whose values are the product of each pair of elements in two specified vectors.
*/
static multiply(v1: Vector2, v2: Vector2): Vector2;
/**
* Divides the first vector by the second.
*/
static divide(v1: Vector2, v2: Vector2): Vector2;
/**
* Adds the scalar value s to this vector's x, y values.
*/
static addScalar(v: Vector2, s: number): Vector2;
/**
* Subtracts the scalar value s to this vector's x, y values.
*/
static subScalar(v: Vector2, s: number): Vector2;
/**
* Multiplies a vector by a specified scalar.
*/
static multiplyScalar(v: Vector2, s: number): Vector2;
/**
* Divides the specified vector by a specified scalar value.
*/
static divideScalar(v: Vector2, s: number): Vector2;
/**
* Returns the dot product of two vectors.
*/
static dot(v1: Vector2, v2: Vector2): number;
/**
* Returns the cross product of two vectors.
*/
static cross(v1: Vector2, v2: Vector2): number;
/**
* Returns a vector with the same direction as the specified vector, but with a length of one.
*/
static normalize(v: Vector2): Vector2;
/**
* Linearly interpolate between v1 and v2,
* where alpha is the percent distance along the line - alpha = 0 will be this vector,
* and alpha = 1 will be v.
*/
static lerp(v1: Vector2, v2: Vector2, alpha: number): Vector2;
/**
* Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors.
*/
static max(v1: Vector2, v2: Vector2): Vector2;
/**
* Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors.
*/
static min(v1: Vector2, v2: Vector2): Vector2;
/**
* Restricts a vector between a minimum and a maximum value.
*/
static clamp(v: Vector2, min: Vector2, max: Vector2): Vector2;
/**
* Negates a specified vector.
*/
static negate(v: Vector2): Vector2;
/**
* Returns a vector whose elements are the absolute values of each of the specified vector's elements.
*/
static abs(v: Vector2): Vector2;
/**
* Transforms a vector by a specified 3x3 matrix.
*/
static applyMat3(v: Vector2, m: Matrix3): Vector2;
/**
* Transforms a vector by a specified 4x4 matrix.
*/
static applyMat4(v: Vector2, m: Matrix4): Vector2;
/**
* Transforms a vector by the specified Quaternion rotation value.
*/
static applyQuat(v: Vector2, q: Quaternion): Vector2;
}