UNPKG

arcade-physics

Version:
402 lines 12 kB
/** * @author Richard Davey <rich@photonstorm.com> * @copyright 2020 Photon Storm Ltd. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * @classdesc * A representation of a vector in 2D space. * * A two-component vector. * * @class Vector2 * @memberof Phaser.Math * @constructor * @since 3.0.0 * * @param {number|Phaser.Types.Math.Vector2Like} [x] - The x component, or an object with `x` and `y` properties. * @param {number} [y] - The y component. */ export declare class Vector2 { x: number; y: number; static ZERO: Vector2; static RIGHT: Vector2; static LEFT: Vector2; static UP: Vector2; static DOWN: Vector2; static ONE: Vector2; constructor(x?: any, y?: any); /** * Make a clone of this Vector2. * * @method Phaser.Math.Vector2#clone * @since 3.0.0 * * @return {Phaser.Math.Vector2} A clone of this Vector2. */ clone(): Vector2; /** * Copy the components of a given Vector into this Vector. * * @method Phaser.Math.Vector2#copy * @since 3.0.0 * * @param {Phaser.Types.Math.Vector2Like} src - The Vector to copy the components from. * * @return {Phaser.Math.Vector2} This Vector2. */ copy(src: any): this; /** * Set the component values of this Vector from a given Vector2Like object. * * @method Phaser.Math.Vector2#setFromObject * @since 3.0.0 * * @param {Phaser.Types.Math.Vector2Like} obj - The object containing the component values to set for this Vector. * * @return {Phaser.Math.Vector2} This Vector2. */ setFromObject(obj: any): this; /** * Set the `x` and `y` components of the this Vector to the given `x` and `y` values. * * @method Phaser.Math.Vector2#set * @since 3.0.0 * * @param {number} x - The x value to set for this Vector. * @param {number} [y=x] - The y value to set for this Vector. * * @return {Phaser.Math.Vector2} This Vector2. */ set(x: any, y?: any): this; /** * This method is an alias for `Vector2.set`. * * @method Phaser.Math.Vector2#setTo * @since 3.4.0 * * @param {number} x - The x value to set for this Vector. * @param {number} [y=x] - The y value to set for this Vector. * * @return {Phaser.Math.Vector2} This Vector2. */ setTo(x: any, y: any): this; /** * Sets the `x` and `y` values of this object from a given polar coordinate. * * @method Phaser.Math.Vector2#setToPolar * @since 3.0.0 * * @param {number} azimuth - The angular coordinate, in radians. * @param {number} [radius=1] - The radial coordinate (length). * * @return {Phaser.Math.Vector2} This Vector2. */ setToPolar(azimuth: any, radius: any): this; /** * Check whether this Vector is equal to a given Vector. * * Performs a strict equality check against each Vector's components. * * @method Phaser.Math.Vector2#equals * @since 3.0.0 * * @param {Phaser.Types.Math.Vector2Like} v - The vector to compare with this Vector. * * @return {boolean} Whether the given Vector is equal to this Vector. */ equals(v: any): boolean; /** * Check whether this Vector is approximately equal to a given Vector. * * @method Phaser.Math.Vector2#fuzzyEquals * @since 3.23.0 * * @param {Phaser.Types.Math.Vector2Like} v - The vector to compare with this Vector. * @param {number} [epsilon=0.0001] - The tolerance value. * * @return {boolean} Whether both absolute differences of the x and y components are smaller than `epsilon`. */ fuzzyEquals(v: any, epsilon: any): any; /** * Calculate the angle between this Vector and the positive x-axis, in radians. * * @method Phaser.Math.Vector2#angle * @since 3.0.0 * * @return {number} The angle between this Vector, and the positive x-axis, given in radians. */ angle(): number; /** * Set the angle of this Vector. * * @method Phaser.Math.Vector2#setAngle * @since 3.23.0 * * @param {number} angle - The angle, in radians. * * @return {Phaser.Math.Vector2} This Vector2. */ setAngle(angle: any): this; /** * Add a given Vector to this Vector. Addition is component-wise. * * @method Phaser.Math.Vector2#add * @since 3.0.0 * * @param {Phaser.Types.Math.Vector2Like} src - The Vector to add to this Vector. * * @return {Phaser.Math.Vector2} This Vector2. */ add(src: Vector2): this; /** * Subtract the given Vector from this Vector. Subtraction is component-wise. * * @method Phaser.Math.Vector2#subtract * @since 3.0.0 * * @param {Phaser.Types.Math.Vector2Like} src - The Vector to subtract from this Vector. * * @return {Phaser.Math.Vector2} This Vector2. */ subtract(src: Vector2): this; /** * Perform a component-wise multiplication between this Vector and the given Vector. * * Multiplies this Vector by the given Vector. * * @method Phaser.Math.Vector2#multiply * @since 3.0.0 * * @param {Phaser.Types.Math.Vector2Like} src - The Vector to multiply this Vector by. * * @return {Phaser.Math.Vector2} This Vector2. */ multiply(src: any): this; /** * Scale this Vector by the given value. * * @method Phaser.Math.Vector2#scale * @since 3.0.0 * * @param {number} value - The value to scale this Vector by. * * @return {Phaser.Math.Vector2} This Vector2. */ scale(value: any): this; /** * Perform a component-wise division between this Vector and the given Vector. * * Divides this Vector by the given Vector. * * @method Phaser.Math.Vector2#divide * @since 3.0.0 * * @param {Phaser.Types.Math.Vector2Like} src - The Vector to divide this Vector by. * * @return {Phaser.Math.Vector2} This Vector2. */ divide(src: any): this; /** * Negate the `x` and `y` components of this Vector. * * @method Phaser.Math.Vector2#negate * @since 3.0.0 * * @return {Phaser.Math.Vector2} This Vector2. */ negate(): this; /** * Calculate the distance between this Vector and the given Vector. * * @method Phaser.Math.Vector2#distance * @since 3.0.0 * * @param {Phaser.Types.Math.Vector2Like} src - The Vector to calculate the distance to. * * @return {number} The distance from this Vector to the given Vector. */ distance(src: any): number; /** * Calculate the distance between this Vector and the given Vector, squared. * * @method Phaser.Math.Vector2#distanceSq * @since 3.0.0 * * @param {Phaser.Types.Math.Vector2Like} src - The Vector to calculate the distance to. * * @return {number} The distance from this Vector to the given Vector, squared. */ distanceSq(src: any): number; /** * Calculate the length (or magnitude) of this Vector. * * @method Phaser.Math.Vector2#length * @since 3.0.0 * * @return {number} The length of this Vector. */ length(): number; /** * Set the length (or magnitude) of this Vector. * * @method Phaser.Math.Vector2#setLength * @since 3.23.0 * * @param {number} length * * @return {Phaser.Math.Vector2} This Vector2. */ setLength(length: any): this; /** * Calculate the length of this Vector squared. * * @method Phaser.Math.Vector2#lengthSq * @since 3.0.0 * * @return {number} The length of this Vector, squared. */ lengthSq(): number; /** * Normalize this Vector. * * Makes the vector a unit length vector (magnitude of 1) in the same direction. * * @method Phaser.Math.Vector2#normalize * @since 3.0.0 * * @return {Phaser.Math.Vector2} This Vector2. */ normalize(): this; /** * Rotate this Vector to its perpendicular, in the positive direction. * * @method Phaser.Math.Vector2#normalizeRightHand * @since 3.0.0 * * @return {Phaser.Math.Vector2} This Vector2. */ normalizeRightHand(): this; /** * Rotate this Vector to its perpendicular, in the negative direction. * * @method Phaser.Math.Vector2#normalizeLeftHand * @since 3.23.0 * * @return {Phaser.Math.Vector2} This Vector2. */ normalizeLeftHand(): this; /** * Calculate the dot product of this Vector and the given Vector. * * @method Phaser.Math.Vector2#dot * @since 3.0.0 * * @param {Phaser.Types.Math.Vector2Like} src - The Vector2 to dot product with this Vector2. * * @return {number} The dot product of this Vector and the given Vector. */ dot(src: any): number; /** * Calculate the cross product of this Vector and the given Vector. * * @method Phaser.Math.Vector2#cross * @since 3.0.0 * * @param {Phaser.Types.Math.Vector2Like} src - The Vector2 to cross with this Vector2. * * @return {number} The cross product of this Vector and the given Vector. */ cross(src: any): number; /** * Linearly interpolate between this Vector and the given Vector. * * Interpolates this Vector towards the given Vector. * * @method Phaser.Math.Vector2#lerp * @since 3.0.0 * * @param {Phaser.Types.Math.Vector2Like} src - The Vector2 to interpolate towards. * @param {number} [t=0] - The interpolation percentage, between 0 and 1. * * @return {Phaser.Math.Vector2} This Vector2. */ lerp(src: any, t: any): this; /** * Transform this Vector with the given Matrix. * * @method Phaser.Math.Vector2#transformMat3 * @since 3.0.0 * * @param {Phaser.Math.Matrix3} mat - The Matrix3 to transform this Vector2 with. * * @return {Phaser.Math.Vector2} This Vector2. */ transformMat3(mat: any): this; /** * Transform this Vector with the given Matrix. * * @method Phaser.Math.Vector2#transformMat4 * @since 3.0.0 * * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector2 with. * * @return {Phaser.Math.Vector2} This Vector2. */ transformMat4(mat: any): this; /** * Make this Vector the zero vector (0, 0). * * @method Phaser.Math.Vector2#reset * @since 3.0.0 * * @return {Phaser.Math.Vector2} This Vector2. */ reset(): this; /** * Limit the length (or magnitude) of this Vector. * * @method Phaser.Math.Vector2#limit * @since 3.23.0 * * @param {number} max - The maximum length. * * @return {Phaser.Math.Vector2} This Vector2. */ limit(max: any): this; /** * Reflect this Vector off a line defined by a normal. * * @method Phaser.Math.Vector2#reflect * @since 3.23.0 * * @param {Phaser.Math.Vector2} normal - A vector perpendicular to the line. * * @return {Phaser.Math.Vector2} This Vector2. */ reflect(normal: any): this; /** * Reflect this Vector across another. * * @method Phaser.Math.Vector2#mirror * @since 3.23.0 * * @param {Phaser.Math.Vector2} axis - A vector to reflect across. * * @return {Phaser.Math.Vector2} This Vector2. */ mirror(axis: any): this; /** * Rotate this Vector by an angle amount. * * @method Phaser.Math.Vector2#rotate * @since 3.23.0 * * @param {number} delta - The angle to rotate by, in radians. * * @return {Phaser.Math.Vector2} This Vector2. */ rotate(delta: any): this; } //# sourceMappingURL=Vector2.d.ts.map