# minerva

• #### Declaration

``` enum Vector3Pos: int; ```

Enum representing the single components of a `Vector3`. (Only used for the `downgrade` function.)

eXodiquas

#### Date

September 24, 2021

• #### Declaration

``` struct Vector2; ```

Struct representing a 2-dimensional vector.

eXodiquas

#### Date

September 24, 2021

• #### Declaration

``` struct Vector3; ```

Struct representing a 3-dimensional vector.

eXodiquas

#### Date

September 24, 2021

• #### Declaration

``` pure nothrow @nogc @safe Vector2 zero2(); ```

Creates the 2 dimensional origin (0,0).

eXodiquas

#### Date

September 24, 2021

#### Return Value

Vector2(0.0, 0.0)

• #### Declaration

``` pure nothrow @nogc @safe Vector2 add(Vector2 v1, Vector2 v2); ```

Adds two vectors `v1` and `v2` components wise.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector2 v1 ``` is the left hand side of the addition. ``` Vector2 v2 ``` is the right hand side of the addition.

#### Return Value

A `Vector2` representing the addition of `v1` and `v2`.

• #### Declaration

``` pure nothrow @nogc @safe Vector2 scale(Vector2 v, double scalar); ```

Scales a vector `v` by a given number `scalar`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector2 v ``` is the vector to `scale`. ``` double scalar ``` is the amount the vector gets scaled.

#### Return Value

A `Vector2` representing the scaled version of `v`.

• #### Declaration

``` pure nothrow @nogc @safe double mag(Vector2 v); ```

Calculates the magnitude (or length) of `v`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector2 v ``` is the vector we want the magnitude of.

#### Return Value

A `double` representing the magnitude of `v`.

• #### Declaration

``` pure nothrow @nogc @safe Vector2 norm(Vector2 v); ```

Calculates the normalized version of `v`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector2 v ``` is the vector we want to normalize.

#### Return Value

A `Vector2` representing the normalized version of `v`.

• #### Declaration

``` pure nothrow @nogc @safe double cross(Vector2 v1, Vector2 v2); ```

Calculates the `cross` product of `v1` and `v2`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector2 v1 ``` is the left hand side of the `cross` product. ``` Vector2 v2 ``` is the right hand side of the `cross` product.

#### Return Value

A `double` representing the `cross` product of `v1` and '`v2`'.

• #### Declaration

``` pure nothrow @nogc @safe double dot(Vector2 v1, Vector2 v2); ```

Calculates the `dot` product (or scalar product) of `v1` and `v2`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector2 v1 ``` is the left hand side of the `dot` product. ``` Vector2 v2 ``` is the right hand side of the `dot` product.

#### Return Value

A `double` representing the `dot` product of `v1` and '`v2`'.

• #### Declaration

``` pure nothrow @nogc @safe double angle(Vector2 v1, Vector2 v2); ```

Calculates the `angle` between `v1` and `v2`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector2 v1 ``` is the first vector. ``` Vector2 v2 ``` is the second vector.

#### Return Value

A `double` in radians representing the `angle` between `v1` and '`v2`'.

• #### Declaration

``` pure nothrow @nogc @safe Vector2 swap(Vector2 v); ```

Swaps the x and the y value of `v`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector2 v ``` is the vector we want to `swap`.

#### Return Value

A `Vector2` with swapped components in comparison to `v`.

• #### Declaration

``` pure nothrow @nogc @safe Vector3 upgrade(Vector2 v); ```

Adds a new dimension to `v`, making it a `Vector3`. The new dimension has default value 0.0.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector2 v ``` is the vector we want to add a new dimension.

#### Return Value

A `Vector3` with `v`s x and y value und z equals to 0.0.

• #### Declaration

``` pure nothrow @nogc @safe Vector3 zero3(); ```

Creates the 3 dimensional origin (0,0,0).

eXodiquas

#### Date

September 24, 2021

#### Return Value

Vector3(0.0, 0.0, 0.0)

• #### Declaration

``` pure nothrow @nogc @safe Vector3 add(Vector3 v1, Vector3 v2); ```

Adds two vectors `v1` and `v2` components wise.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector3 v1 ``` is the left hand side of the addition. ``` Vector3 v2 ``` is the right hand side of the addition.

#### Return Value

A `Vector3` representing the addition of `v1` and `v2`.

• #### Declaration

``` pure nothrow @nogc @safe Vector3 scale(Vector3 v, double scalar); ```

Scales a vector `v` by a given number `scalar`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector3 v ``` is the vector to `scale`. ``` double scalar ``` is the amount the vector gets scaled.

#### Return Value

A `Vector3` representing the scaled version of `v`.

• #### Declaration

``` pure nothrow @nogc @safe double mag(Vector3 v); ```

Calculates the magnitude (or length) of `v`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector3 v ``` is the vector we want the magnitude of.

#### Return Value

A `double` representing the magnitude of `v`.

• #### Declaration

``` pure nothrow @nogc @safe Vector3 norm(Vector3 v); ```

Calculates the normalized version of `v`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector3 v ``` is the vector we want to normalize.

#### Return Value

A `Vector3` representing the normalized version of `v`.

• #### Declaration

``` pure nothrow @nogc @safe Vector3 cross(Vector3 v1, Vector3 v2); ```

Calculates the `cross` product of `v1` and `v2`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector3 v1 ``` is the left hand side of the `cross` product. ``` Vector3 v2 ``` is the right hand side of the `cross` product.

#### Return Value

A `Vector3` representing the `cross` product of `v1` and '`v2`'.

• #### Declaration

``` pure nothrow @nogc @safe double dot(Vector3 v1, Vector3 v2); ```

Calculates the `dot` product (or scalar product) of `v1` and `v2`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector3 v1 ``` is the left hand side of the `dot` product. ``` Vector3 v2 ``` is the right hand side of the `dot` product.

#### Return Value

A `double` representing the `dot` product of `v1` and '`v2`'.

• #### Declaration

``` pure nothrow @nogc @safe double angle(Vector3 v1, Vector3 v2); ```

Calculates the `angle` between `v1` and `v2`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector3 v1 ``` is the first vector. ``` Vector3 v2 ``` is the second vector.

#### Return Value

A `double` in radians representing the `angle` between `v1` and '`v2`'.

• #### Declaration

``` pure nothrow @nogc @safe Vector3 swapLeft(Vector3 v); ```

Swaps the x, y and z values of `v` to the left, so x becomes y, y becomes z and z becomes x.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector3 v ``` is the vector we want to swap to the left.

#### Return Value

A `Vector3` with swapped components in comparison to `v`.

• #### Declaration

``` pure nothrow @nogc @safe Vector3 swapRight(Vector3 v); ```

Swaps the x, y and z values of `v` to the right, so x becomes z, y becomes a and z becomes y.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector3 v ``` is the vector we want to swap to the left.

#### Return Value

A `Vector3` with swapped components in comparison to `v`.

• #### Declaration

``` pure nothrow @nogc @safe Vector2 downgrade(Vector3 v, Vector3Pos vp); ```

Downgrades the given `Vector3` to a `Vector2` removing the one component denoted by `vp`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector3 v ``` is the vector we want to `downgrade`. ``` Vector3Pos vp ``` the component we want to remove.

#### Return Value

A `Vector2` with the same components as `v` except the removed one.

#### Examples

1. ```Vector3(1.0, 2.0, 3.0).downgrade(Vector3Pos.X); //Vector2(2.0, 3.0) ```

• #### Declaration

``` struct Matrix2x2; ```

Struct representing a 2x2 matrix in the form: a b c d

• #### Declaration

``` struct Matrix3x3; ```

Struct representing a 3x3 matrix in the form: a b c d e f g h i

• #### Declaration

``` pure nothrow @nogc @safe Matrix2x2 unit2x2(); ```

Creates a 2x2 unit matrix in the form: 1.0 0.0 0.0 1.0

eXodiquas

#### Date

September 24, 2021

#### Return Value

The unit matrix of type `Matrix2x2`.

• #### Declaration

``` pure nothrow @safe Vector2[] rowVectors(Matrix2x2 m); ```

Extract the row vectors of a given matrix. The vectors are read like this: a b c d => (a, b), (c, d)

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Matrix2x2 m ``` is the matrix from which the row vectors should be be extracted.

#### Return Value

A `Vector2[]` containg all the row vectors.

• #### Declaration

``` pure nothrow @safe Vector2[] colVectors(Matrix2x2 m); ```

Extract the column vectors of a given matrix. The vectors are read like this: a b c d => (a, c), (b, d)

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Matrix2x2 m ``` is the matrix from which the column vectors should be be extracted.

#### Return Value

A `Vector2[]` containg all the column vectors.

• #### Declaration

``` pure nothrow @nogc @safe Matrix2x2 scale(Matrix2x2 m, double scalar); ```

Scale a given `Matrix2x2` `m` by a given `scalar`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Matrix2x2 m ``` is the matrix we want to `scale`. ``` double scalar ``` is the amount we want to `scale`.

#### Return Value

A scaled version of our input `Matrix2x2` `m`.

• #### Declaration

``` pure nothrow @nogc @safe Matrix2x2 mult(Matrix2x2 m1, Matrix2x2 m2); ```

Mutliplies two `Matrix2x2` with eachother.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Matrix2x2 m1 ``` is the left hand side matrix. ``` Matrix2x2 m2 ``` is the right hand side matrix.

#### Return Value

The resulting `Matrix2x2` from the multiplication.

• #### Declaration

``` pure nothrow @nogc @safe Vector2 mult(Matrix2x2 m, Vector2 v); ```

Mutliplies a `Matrix2x2` and a `Vector2` with eachother.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Matrix2x2 m ``` is the matrix. ``` Vector2 v ``` is the vector.

#### Return Value

The resulting `Vector2` from the multiplication.

• #### Declaration

``` pure nothrow @nogc @safe Vector2 rotateClockwise(Vector2 v, double angle); ```

Rotates a given `Vector2` by an `angle` in radians in clockwise direction.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector2 v ``` is the vector. ``` double angle ``` is the `angle` in radians.

#### Return Value

The resulting `Vector2` from the rotation.

• #### Declaration

``` pure nothrow @nogc @safe Vector2 rotateCounterClockwise(Vector2 v, double angle); ```

Rotates a given `Vector2` by an `angle` in radians in counter clockwise direction.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector2 v ``` is the vector. ``` double angle ``` is the `angle` in radians.

#### Return Value

The resulting `Vector2` from the rotation.

• #### Declaration

``` pure nothrow @nogc @safe Matrix3x3 unit3x3(); ```

Creates a 3x3 unit matrix in the form: 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0

eXodiquas

#### Date

September 24, 2021

#### Return Value

The unit matrix of type `Matrix3x3`.

• #### Declaration

``` pure nothrow @safe Vector3[] rowVectors(Matrix3x3 m); ```

Extract the row vectors of a given matrix. The vectors are read like this: a b c d e f g h i => (a, b, c), (d, e, f), (g, h, i)

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Matrix3x3 m ``` is the matrix from which the row vectors should be be extracted.

#### Return Value

A `Vector3[]` containg all the row vectors.

• #### Declaration

``` pure nothrow @safe Vector3[] colVectors(Matrix3x3 m); ```

Extract the column vectors of a given matrix. The vectors are read like this: a b c d e f g h i => (a, d, g), (b, e, h), (c, f, i)

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Matrix3x3 m ``` is the matrix from which the column vectors should be be extracted.

#### Return Value

A `Vector3[]` containg all the column vectors.

• #### Declaration

``` pure nothrow @nogc @safe Matrix3x3 scale(Matrix3x3 m, double scalar); ```

Scale a given `Matrix3x3` `m` by a given `scalar`.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Matrix3x3 m ``` is the matrix we want to `scale`. ``` double scalar ``` is the amount we want to `scale`.

#### Return Value

A scaled version of our input `Matrix3x3` `m`.

• #### Declaration

``` pure nothrow @nogc @safe Matrix3x3 mult(Matrix3x3 m1, Matrix3x3 m2); ```

Mutliplies two `Matrix3x3` with eachother.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Matrix3x3 m1 ``` is the left hand side matrix. ``` Matrix3x3 m2 ``` is the right hand side matrix.

#### Return Value

The resulting `Matrix3x3` from the multiplication.

• #### Declaration

``` pure nothrow @nogc @safe Vector3 mult(Matrix3x3 m, Vector3 v); ```

Mutliplies a `Matrix3x3` and a `Vector3` with eachother.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Matrix3x3 m ``` is the matrix. ``` Vector3 v ``` is the vector.

#### Return Value

The resulting `Vector3` from the multiplication.

• #### Declaration

``` pure nothrow @nogc @safe Vector3 rotateX(Vector3 v, double angle); ```

Rotates a given `Vector3` by an `angle` in radians in counter clockwise direction around the x-axis.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector3 v ``` is the vector. ``` double angle ``` is the `angle` in radians.

#### Return Value

The resulting `Vector3` from the rotation.

• #### Declaration

``` pure nothrow @nogc @safe Vector3 rotateY(Vector3 v, double angle); ```

Rotates a given `Vector3` by an `angle` in radians in counter clockwise direction around the y-axis.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector3 v ``` is the vector. ``` double angle ``` is the `angle` in radians.

#### Return Value

The resulting `Vector3` from the rotation.

• #### Declaration

``` pure nothrow @nogc @safe Vector3 rotateZ(Vector3 v, double angle); ```

Rotates a given `Vector3` by an `angle` in radians in counter clockwise direction around the z-axis.

eXodiquas

#### Date

September 24, 2021

#### Parameters

 ``` Vector3 v ``` is the vector. ``` double angle ``` is the `angle` in radians.

#### Return Value

The resulting `Vector3` from the rotation.

• #### Declaration

``` struct Vector(size_t dimension); ```

Struct representing a N-dimensional vector. This struct only works for vectors with more than 3 dimensions.

eXodiquas

#### Date

September 28, 2021

#### Examples

1. ```Vector!5 v = Vector!5([1,2,3,4,5]); v.x0.writeln; // 1 v.x1.writeln; // 2 ```

#### Throws

Exception whenever the supplied list of values has not the same length as the supplied dimension of the vector or when the supplied dimension is less than 4.

• #### Declaration

``` pure @safe Vector!dim zeroN(size_t dim)(); ```

Creates a `Vector!dim` filled with `dim` `0.0`s.

eXodiquas

#### Date

September 28, 2021

#### Parameters

 ``` dim ``` is the number of dimensions.

#### Return Value

A `Vector!dim` filled with `dim` `0.0`s.

• #### Declaration

``` pure @safe Vector!dim add(size_t dim)(Vector!dim v1, Vector!dim v2); ```

Adds two `Vector!dim` with the same dimensions component wise.

eXodiquas

#### Date

September 28, 2021

#### Parameters

 ``` lhs ``` is the left hand side of the addition. ``` rhs ``` is the right hand side of the addition.

#### Return Value

A `Vector!dim` representing the addition of `v1` and `v2`.

• #### Declaration

``` pure @safe Vector!dim scale(size_t dim)(Vector!dim v, double scalar); ```

Scales a vector `v` by a given number `scalar`.

eXodiquas

#### Date

September 28, 2021

#### Parameters

 ``` Vector!dim v ``` is the vector to `scale`. ``` double scalar ``` is the amount the vector gets scaled.

#### Return Value

A `Vector!dim` representing the scaled version of `v`.

• #### Declaration

``` pure @safe double mag(size_t dim)(Vector!dim v); ```

Calculates the magnitude (or length) of `v`.

eXodiquas

#### Date

September 28, 2021

#### Parameters

 ``` Vector!dim v ``` is the vector we want the magnitude of.

#### Return Value

A `double` representing the magnitude of `v`.

• #### Declaration

``` pure @safe Vector!dim norm(size_t dim)(Vector!dim v); ```

Calculates the normalized version of `v`.

eXodiquas

#### Date

September 28, 2021

#### Parameters

 ``` Vector!dim v ``` is the vector we want to normalize.

#### Return Value

A `Vector!dim` representing the normalized version of `v`.

• #### Declaration

``` pure @safe double dot(size_t dim)(Vector!dim v1, Vector!dim v2); ```

Calculates the `dot` product of `v1` and `v2`.

eXodiquas

#### Date

September 28, 2021

#### Parameters

 ``` Vector!dim v1 ``` is the left hand side of the calculation. ``` Vector!dim v2 ``` is the right hand side of the calculation.

#### Return Value

A `double` representing the `dot` product of `v1` and `v2`.

• #### Declaration

``` pure @safe double angle(size_t dim)(Vector!dim v1, Vector!dim v2); ```

Calculates the `angle` between `v1` and `v2`.

eXodiquas

#### Date

September 28, 2021

#### Parameters

 ``` Vector!dim v1 ``` is the first vector. ``` Vector!dim v2 ``` is the second vector.

#### Return Value

A `double` in radians representing the `angle` between `v1` and '`v2`'.

• #### Declaration

``` pure @safe Vector!(dim + 1) upgrade(size_t dim)(Vector!dim v); ```

Adds a dimension to `v`, making it a `Vector!(dim + 1)`. The new dimension has default value 0.0.

eXodiquas

#### Date

September 28, 2021

#### Parameters

 ``` Vector!dim v ``` is the vector we want to add a new dimension.

#### Return Value

A `Vector!(dim + 1)` with an additional `0.0` as a component.