ts-scikit
Version:
A scientific toolkit written in Typescript
85 lines (84 loc) • 2.38 kB
TypeScript
import { Tuple2 } from './tuple2';
/**
* A vector with 2 components: x and y.
*/
export declare class Vector2 extends Tuple2 {
/**
* Constructs a new vector with two components.
* @param x the x-component.
* @param y the y-component.
*/
constructor(x: number, y: number);
/**
* The length of this vector.
* @returns the length of this vector.
*/
get length(): number;
/**
* The length of this vector, squared.
* @returns the length of this vector, squared.
*/
get lengthSquared(): number;
/**
* Computes the negation -u of this vector u.
* @returns the negation.
*/
negate(): Vector2;
/**
* Sets this vector to its negation.
* @returns a reference to this vector.
*/
negateEquals(): this;
/**
* Computes the unit vector with the same direction as this vector.
* @returns the unit vector.
*/
normalize(): Vector2;
/**
* Sets this vector to its unit vector.
* @returns a reference to this vector.
*/
normalizeEquals(): this;
/**
* Returns the vector sum u + v for this vector u
* @param v the other vector.
* @returns the vector sum u + v.
*/
plus(v: Vector2): Vector2;
/**
* Adds a vector v to this vector u.
* @param v the other vector.
* @returns a reference to this vector, after adding vector v.
*/
plusEquals(v: Vector2): this;
/**
* Returns the vector difference u - v for this vector u.
* @param v the other vector.
* @returns the vector difference u - v.
*/
minus(v: Vector2): Vector2;
/**
* Subtracts a vector v from this vector u.
* @param v the other vector.
* @returns a reference to this vector, after subtracting vector v.
*/
minusEquals(v: Vector2): this;
/**
* Returns the scaled vector s * u for this vector u.
* @param s the scale factor.
* @returns the scaled vector.
*/
times(s: number): Vector2;
/**
* Scales this vector.
* @param s the scale factor.
* @returns a reference to this vector, after scaling.
*/
timesEquals(s: number): this;
/**
* Computes the dot product of this vector and the specified vector v.
* @param v the vector v.
* @returns the dot product.
*/
dot(v: Vector2): number;
}