Class Vector

A vector is an object representing distance in vertical and horizontal directions in multidimensional space Components are the first template parameter with the second template parameter being vector dimensionality Most vector operations take advantage of parallelism to do simple arithmetic on each component in parallel

class Vector(T, uint dimensions) ;

Constructors

NameDescription
this A vector constructor; takes in the number of args given and assigns them as components
this A vector constructor; takes in a value that acts as both vector components
this A constructor that sets all elements to 0
this A copy constructor for a vector; makes the same vector, but as a different instance

Fields

NameTypeDescription
components T[dimensions]The components of the vector
w TThe components of the vector
x TThe components of the vector
y TThe components of the vector
z TThe components of the vector

Properties

NameTypeDescription
directionAngles[set] Vector!(double,dimensions)Sets the angles of the vector where the angles are given in radians Angles are direction angles (eg. first angle is direction from x, second is direction from y, etc...) 0 goes along the positive axis
directionAngles[get] Vector!(double,dimensions)Gets the angles of the vector where the angles are given in radians Angles are direction angles (eg. first angle is direction from x, second is direction from y, etc...) 0 goes along the positive axis
magnitude[set] doubleSets the length of the vector Maintains component ratios of the vector
magnitude[get] doubleGets the length of the vector

Methods

NameDescription
apply Applies the given function to each element of the vector
apply Applies the given function to each element of the vector and returns the results in a new vector
opAssign Allows assigning the vector to a static array to set all components of the vector
opAssign Allows assigning the vector to a single value to set all elements of the vector to such a value
opBinary Allows the vector to be used with normal operators Works component-wise (eg. (3, 2, 1) + (1, 2, 3) = (4, 4, 4))
opBinary Allows the vector to be used with normal operators Works component-wise, so each operation of the constant is applied to each component
opCast Casts the vector to a vector of another type
opEquals Returns whether the vector is equal to another vector or constant Uses approxEquals to do easy equality for vectors of doubles
opOpAssign Allows the vector to have the joint operator assign syntax Works component-wise (eg. (3, 2, 1) += (1, 2, 3) makes (3, 2, 1) into (4, 4, 4))
opOpAssign Allows the vector to have the joint operator assign syntax Works component-wise, so each operation of the constant is applied to each component
opUnary Allows unary functions to be applied to the vector; aplies the same operator to all components
toString Gives the vector a pretty string format (eg. (1, 2, 3) => <1, 2, 3>)

TODO

slices returning vectors, swizzling, and dispatch forwarding