lnagb.js Documentation

Vector

Contains the Vector class, which encodes vector quantities of any number of entries in linear algebra.

Author: Zach / cszach@proton.me


Vector~Vector

Encodes vectors and vector operations. Compatible for use with matrices (e.g. for matrix-vector multiplications).

For optimal performance, use Vector2, Vector3, Vector4 if possible.

Kind: inner class of Vector


new Vector(entries)

Constructs a new Vector instance, which encodes a vector and its operations.

Param Type Description
entries Array.<number> Entries of the new vector.

vector.elements : Array.<number>

Stores the entries of this vector in order.

Kind: instance property of Vector


vector.size : object

Contains the dimensions of this vector as an object in the form { rows, columns }. Serve for compatibility with matrix classes.

Kind: instance property of Vector


vector.numberOfEntries : number

The number of entries in this vector.

Kind: instance property of Vector


vector.clone() ⇒ Vector

Creates and returns a clone of this vector instance.

Kind: instance method of Vector
Returns: Vector - A clone of this vector


vector.equals(vector) ⇒ boolean

Checks if this vector and another vector are equal.

Kind: instance method of Vector
Returns: boolean - true if the two vectors are equal, false otherwise

Param Type Description
vector Vector The vector to compare this vector to.

vector.multiplyScalar(k) ⇒ Vector

Multiplies this vector by a scalar.

Kind: instance method of Vector
Returns: Vector - This vector

Param Type Description
k number The scalar to multiply this vector by.

vector.negate() ⇒ Vector

Multiplies this vector by -1.

Kind: instance method of Vector
Returns: Vector - This vector


vector.add(vector) ⇒ Vector

Adds a vector to this vector.

Kind: instance method of Vector
Returns: Vector - This vector

Param Type Description
vector Vector The vector to add to this vector.

vector.subtract(vector) ⇒ Vector

Subtracts a vector from this vector.

Kind: instance method of Vector
Returns: Vector - This vector

Param Type Description
vector Vector The vector to subtract this vector to.

vector.dot(vector) ⇒ Vector

Returns the dot product of this vector and another vector.

Kind: instance method of Vector
Returns: Vector - The dot product of this vector and the given vector

Param Type Description
vector Vector The vector to perform a dot product with this vector.