import * as vec2 from '../glmatrix/vec2'; import type Matrix2 from './Matrix2'; import type Matrix2d from './Matrix2d'; import type Matrix3 from './Matrix3'; import type Matrix4 from './Matrix4'; import Vector3 from './Vector3'; /** * @constructor * @alias clay.Vector2 * @param * @param */ declare class Vector2 { /** * Storage of Vector2, read and write of x, y will change the values in array * All methods also operate on the array instead of x, y components */ array: vec2.Vec2Array; constructor(x?: number, y?: number); get x(): number; set x(value: number); get y(): number; set y(value: number); /** * Add b to self * @param b */ add(b: Vector2): this; /** * Set x and y components * @param x * @param y */ set(x: number, y: number): this; /** * Set x and y components from array * @param arr */ setArray(arr: vec2.Vec2Array): this; /** * Clone a new Vector2 */ clone(): Vector2; /** * Copy x, y from b * @param b */ copy(b: Vector2): this; /** * Cross product of self and b, written to a Vector3 out * @param out * @param b */ cross(out: Vector3, b: Vector2): this; /** * Alias for distance * @param b {number} */ dist(b: Vector2): number; /** * Distance between self and b * @param b {number} */ distance(b: Vector2): number; /** * Alias for divide * @param b */ div(b: Vector2): this; /** * Divide self by b * @param b */ divide(b: Vector2): this; /** * Dot product of self and b * @param b {number} */ dot(b: Vector2): number; /** * Alias of length {number} */ len(): number; /** * Calculate the length {number} */ length(): number; /** * Linear interpolation between a and b * @param a * @param b * @param t */ lerp(a: Vector2, b: Vector2, t: number): this; /** * Minimum of self and b * @param b */ min(b: Vector2): this; /** * Maximum of self and b * @param b */ max(b: Vector2): this; /** * Alias for multiply * @param b */ mul(b: Vector2): this; /** * Mutiply self and b * @param b */ multiply(b: Vector2): this; /** * Negate self */ negate(): this; /** * Normalize self */ normalize(): this; /** * Generate random x, y components with a given scale * @param cale */ random(scale: number): this; /** * Scale self * @param scale */ scale(s: number): this; /** * Scale b and add to self * @param b * @param scale */ scaleAndAdd(b: Vector2, s: number): this; /** * Alias for squaredDistance * @param b {number} */ sqrDist(b: Vector2): number; /** * Squared distance between self and b * @param b {number} */ squaredDistance(b: Vector2): number; /** * Alias for squaredLength {number} */ sqrLen(): number; /** * Squared length of self {number} */ squaredLength(): number; /** * Alias for subtract * @param b */ sub(b: Vector2): this; /** * Subtract b from self * @param b */ subtract(b: Vector2): this; /** * Transform self with a Matrix2 m * @param m */ transformMat2(m: Matrix2): this; /** * Transform self with a Matrix2d m * @param m */ transformMat2d(m: Matrix2d): this; /** * Transform self with a Matrix3 m * @param {clay.Matrix3} m */ transformMat3(m: Matrix3): this; /** * Transform self with a Matrix4 m * @param m */ transformMat4(m: Matrix4): this; toString(): string; toArray(): vec2.Vec2Array; /** * @param out * @param a * @param b */ static add(out: Vector2, a: Vector2, b: Vector2): Vector2; /** * @param out * @param x * @param y */ static set(out: Vector2, x: number, y: number): Vector2; /** * @param out * @param b */ static copy(out: Vector2, b: Vector2): Vector2; /** * @param out * @param a * @param b */ static cross(out: Vector3, a: Vector2, b: Vector2): Vector3; /** * @param a * @param b {number} */ static dist(a: Vector2, b: Vector2): number; /** * @function * @param a * @param b {number} */ static distance: typeof Vector2.dist; /** * @param out * @param a * @param b */ static div(out: Vector2, a: Vector2, b: Vector2): Vector2; /** * @function * @param out * @param a * @param b */ static divide: typeof Vector2.div; /** * @param a * @param b {number} */ static dot(a: Vector2, b: Vector2): number; /** * @param a {number} */ static len(b: Vector2): number; /** * @param out * @param a * @param b * @param t */ static lerp(out: Vector2, a: Vector2, b: Vector2, t: number): Vector2; /** * @param out * @param a * @param b */ static min(out: Vector2, a: Vector2, b: Vector2): Vector2; /** * @param out * @param a * @param b */ static max(out: Vector2, a: Vector2, b: Vector2): Vector2; /** * @param out * @param a * @param b */ static mul(out: Vector2, a: Vector2, b: Vector2): Vector2; /** * @function * @param out * @param a * @param b */ static multiply: typeof Vector2.mul; /** * @param out * @param a */ static negate(out: Vector2, a: Vector2): Vector2; /** * @param out * @param a */ static normalize(out: Vector2, a: Vector2): Vector2; /** * @param out * @param scale */ static random(out: Vector2, scale: number): Vector2; /** * @param out * @param a * @param scale */ static scale(out: Vector2, a: Vector2, scale: number): Vector2; /** * @param out * @param a * @param b * @param scale */ static scaleAndAdd(out: Vector2, a: Vector2, b: Vector2, scale: number): Vector2; /** * @param a * @param b {number} */ static sqrDist(a: Vector2, b: Vector2): number; /** * @function * @param a * @param b {number} */ static squaredDistance: typeof Vector2.sqrDist; /** * @param a {number} */ static sqrLen(a: Vector2): number; /** * @function * @param a */ static squaredLength: typeof Vector2.sqrLen; /** * @param out * @param a * @param b */ static sub(out: Vector2, a: Vector2, b: Vector2): Vector2; /** * @function * @param out * @param a * @param b */ static subtract: typeof Vector2.sub; /** * @param out * @param a * @param m */ static transformMat2(out: Vector2, a: Vector2, m: Matrix2): Vector2; /** * @param out * @param a * @param m */ static transformMat2d(out: Vector2, a: Vector2, m: Matrix2d): Vector2; /** * @param out * @param a * @param m */ static transformMat3(out: Vector2, a: Vector2, m: Matrix3): Vector2; /** * @param out * @param a * @param m */ static transformMat4(out: Vector2, a: Vector2, m: Matrix4): Vector2; } export default Vector2;