Class: Vector

LinearAlgebra. Vector


new Vector()

This class represents an element of Euclidean 3-space, along with all the usual
vector space operations (addition, multiplication by scalars, etc.).

Properties:
Name Type Description
x number

The x component of this vector. Default value is 0.

y number

The y component of this vector. Default value is 0.

z number

The z component of this vector. Default value is 0.

Methods


norm()

Computes the Euclidean length of this vector.

Returns:
Type
number

norm2()

Computes the Euclidean length squared of this vector.

Returns:
Type
number

normalize()

Divides this vector by its Euclidean length.


unit()

Returns a normalized copy of this vector.

Returns:
Type
module:LinearAlgebra.Vector

isValid()

Checks whether this vector's components are finite.

Returns:
Type
boolean

incrementBy(v)

u += v

Parameters:
Name Type Description
v module:LinearAlgebra.Vector

The vector added to this vector.


decrementBy(v)

u -= v

Parameters:
Name Type Description
v module:LinearAlgebra.Vector

The vector subtracted from this vector.


scaleBy(s)

u *= s

Parameters:
Name Type Description
s number

The number this vector is scaled by.


divideBy(s)

u /= s

Parameters:
Name Type Description
s number

The number this vector is divided by.


plus(v)

Returns u + v

Parameters:
Name Type Description
v module:LinearAlgebra.Vector

The vector added to this vector.

Returns:
Type
module:LinearAlgebra.Vector

minus(v)

Returns u - v

Parameters:
Name Type Description
v module:LinearAlgebra.Vector

The vector subtracted from this vector.

Returns:
Type
module:LinearAlgebra.Vector

times(s)

Returns u * s

Parameters:
Name Type Description
s number

The number this vector is multiplied by.

Returns:
Type
module:LinearAlgebra.Vector

over(s)

Returns u / s

Parameters:
Name Type Description
s number

The number this vector is divided by.

Returns:
Type
module:LinearAlgebra.Vector

negated()

Returns -u

Returns:
Type
module:LinearAlgebra.Vector

dot(v)

Computes the dot product of this vector and v

Parameters:
Name Type Description
v module:LinearAlgebra.Vector

The vector this vector is dotted with.

Returns:
Type
number

cross(v)

Computes the cross product of this vector and v

Parameters:
Name Type Description
v module:LinearAlgebra.Vector

The vector this vector is crossed with.

Returns:
Type
module:LinearAlgebra.Vector