@equinor/videx-vector2
Version:
Vector2 class library written in javascript.
71 lines (70 loc) • 2.36 kB
TypeScript
import Vector2 from './index';
import { VectorLike } from '@equinor/videx-linear-algebra';
/**
* Rotate vector by a given amount of radians.
* @private
* @param v Vector to rotate
* @param rad Angle in radians
* @param target Target for storing the results
* @return Rotated vector
*/
export declare function rotate(v: Vector2, rad: number, target: Vector2): Vector2;
/**
* Rotate vector by 90 degrees. (Counter-clockwise)
* @private
* @param v Vector to rotate
* @param target Target for storing the results
* @return Rotated vector
*/
export declare function rotate90(v: Vector2, target: Vector2): Vector2;
/**
* Flip/Rotate vector by 180 degrees.
* @private
* @param v Vector to rotate
* @param target Target for storing the results
* @return Flipped/rotated vector
*/
export declare function rotate180(v: Vector2, target: Vector2): Vector2;
/**
* Rotate vector by 270 degrees. (Counter-clockwise)
* @private
* @param v Vector to rotate
* @param target Target for storing the results
* @return Rotated vector
*/
export declare function rotate270(v: Vector2, target: Vector2): Vector2;
/**
* Find the cross product between two 2d vectors.
* @private
* @param a Left operand
* @param b Right operand
* @return Signed area of the parallellogram defined by v1 and v2
*/
export declare function cross(a: VectorLike, b: VectorLike): number;
/**
* Find angle (in radians) between vector and right vector, [1, 0].
* @private
* @param v Target vector
* @return Angle in radians
*/
export declare function angleRight(v: VectorLike): number;
/**
* Calculates the signed angle between two vectors.
* @private
* @param a First vector
* @param b Second vector
* @returns Signed angle between vectors
*/
export declare function signedAngle(a: VectorLike, b: VectorLike): number;
/**
* Rotates a vector, v1, towards a second vector, v2, based on a factor, n.
* An n-value of 0.5, will return a vector with rotation in between
* v1 and v2.
* @private
* @param a Vector to interpolate from
* @param b Vector to interpolate to
* @param n Value between 0 - 1 used for interpolation
* @param target Target for storing the results (Default: a)
* @returns Interpolated vector
*/
export declare function lerpRot(a: any, b: any, n: number, target?: any): Vector2;