RedVector:
Filter:
redUniverse/Classes (extension) | Red > redUniverse

RedVector
ExtensionExtension

a vector of any dimension

Description

NOTE: For 2, 3 and 4 dimensional vectors, consider using the subclasses RedVector2D, RedVector3D and RedVector4D. These are optimised for speed.

Instance Methods

.mag

Get the magnitude of the vector as a Float.

.distance

Get the distance between two vectors as a Float. (vec1-vec2).pow(2).sum.sqrt

.manhattan

Get the sum of the absolute differences as a Float. (vec1-vec2).abs.sum.

Discussion:

Sometimes when just comparing distances it is not necessary to perform pow2 and sqrt calculations. In those situations this method will be a lot faster than -distance.

.dot

Dot product.

.normalize

Get a new vector with normalized magnitude.

.limit

Get a new vector limited to max value.

Examples