minerva

Declaration
enum
Vector3Pos
: int;Enum representing the single components of a
Vector3
. (Only used for thedowngrade
function.)Date
September 24, 2021

Declaration
struct
Vector2
;Struct representing a 2dimensional vector.
Date
September 24, 2021

Declaration
struct
Vector3
;Struct representing a 3dimensional vector.
Date
September 24, 2021

Declaration
pure nothrow @nogc @safe Vector2
zero2
();Creates the 2 dimensional origin (0,0).
Date
September 24, 2021
Return Value
Vector2(0.0, 0.0)

Declaration
pure nothrow @nogc @safe Vector2
add
(Vector2v1
, Vector2v2
);Adds two vectors
andv1
components wise.v2
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
andv1
.v2

Declaration
pure nothrow @nogc @safe Vector2
scale
(Vector2v
, doublescalar
);Scales a vector
by a given numberv
.scalar
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
(Vector2v
);Calculates the magnitude (or length) of
.v
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
(Vector2v
);Calculates the normalized version of
.v
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
(Vector2v1
, Vector2v2
);Calculates the
cross
product of
andv1
.v2
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 thecross
product of
and 'v1
v2
'. 
Declaration
pure nothrow @nogc @safe double
dot
(Vector2v1
, Vector2v2
);Calculates the
dot
product (or scalar product) of
andv1
.v2
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 thedot
product of
and 'v1
v2
'. 
Declaration
pure nothrow @nogc @safe double
angle
(Vector2v1
, Vector2v2
);Calculates the
angle
between
andv1
.v2
Date
September 24, 2021
Parameters
Vector2
v1
is the first vector.
Vector2
v2
is the second vector.
Return Value
A
double
in radians representing theangle
between
and 'v1
v2
'. 
Declaration
pure nothrow @nogc @safe Vector2
swap
(Vector2v
);Swaps the x and the y value of
.v
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
(Vector2v
);Adds a new dimension to
, making it av
Vector3
. The new dimension has default value 0.0.Date
September 24, 2021
Parameters
Vector2
v
is the vector we want to add a new dimension.
Return Value
A
Vector3
with
s x and y value und z equals to 0.0.v

Declaration
pure nothrow @nogc @safe Vector3
zero3
();Creates the 3 dimensional origin (0,0,0).
Date
September 24, 2021
Return Value
Vector3(0.0, 0.0, 0.0)

Declaration
pure nothrow @nogc @safe Vector3
add
(Vector3v1
, Vector3v2
);Adds two vectors
andv1
components wise.v2
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
andv1
.v2

Declaration
pure nothrow @nogc @safe Vector3
scale
(Vector3v
, doublescalar
);Scales a vector
by a given numberv
.scalar
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
(Vector3v
);Calculates the magnitude (or length) of
.v
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
(Vector3v
);Calculates the normalized version of
.v
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
(Vector3v1
, Vector3v2
);Calculates the
cross
product of
andv1
.v2
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 thecross
product of
and 'v1
v2
'. 
Declaration
pure nothrow @nogc @safe double
dot
(Vector3v1
, Vector3v2
);Calculates the
dot
product (or scalar product) of
andv1
.v2
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 thedot
product of
and 'v1
v2
'. 
Declaration
pure nothrow @nogc @safe double
angle
(Vector3v1
, Vector3v2
);Calculates the
angle
between
andv1
.v2
Date
September 24, 2021
Parameters
Vector3
v1
is the first vector.
Vector3
v2
is the second vector.
Return Value
A
double
in radians representing theangle
between
and 'v1
v2
'. 
Declaration
pure nothrow @nogc @safe Vector3
swapLeft
(Vector3v
);Swaps the x, y and z values of
to the left, so x becomes y, y becomes z and z becomes x.v
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
(Vector3v
);Swaps the x, y and z values of
to the right, so x becomes z, y becomes a and z becomes y.v
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
(Vector3v
, Vector3Posvp
);Downgrades the given
Vector3
to aVector2
removing the one component denoted by
.vp
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
except the removed one.v
Examples
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
Date
September 24, 2021
Return Value
The unit matrix of type
Matrix2x2
. 
Declaration
pure nothrow @safe Vector2[]
rowVectors
(Matrix2x2m
);Extract the row vectors of a given matrix. The vectors are read like this: a b c d => (a, b), (c, d)
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
(Matrix2x2m
);Extract the column vectors of a given matrix. The vectors are read like this: a b c d => (a, c), (b, d)
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
(Matrix2x2m
, doublescalar
);Scale a given
Matrix2x2
by a givenm
.scalar
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
(Matrix2x2m1
, Matrix2x2m2
);Mutliplies two
Matrix2x2
with eachother.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
(Matrix2x2m
, Vector2v
);Mutliplies a
Matrix2x2
and aVector2
with eachother.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
(Vector2v
, doubleangle
);Rotates a given
Vector2
by an
in radians in clockwise direction.angle
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
(Vector2v
, doubleangle
);Rotates a given
Vector2
by an
in radians in counter clockwise direction.angle
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
Date
September 24, 2021
Return Value
The unit matrix of type
Matrix3x3
. 
Declaration
pure nothrow @safe Vector3[]
rowVectors
(Matrix3x3m
);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)
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
(Matrix3x3m
);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)
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
(Matrix3x3m
, doublescalar
);Scale a given
Matrix3x3
by a givenm
.scalar
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
(Matrix3x3m1
, Matrix3x3m2
);Mutliplies two
Matrix3x3
with eachother.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
(Matrix3x3m
, Vector3v
);Mutliplies a
Matrix3x3
and aVector3
with eachother.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
(Vector3v
, doubleangle
);Rotates a given
Vector3
by an
in radians in counter clockwise direction around the xaxis.angle
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
(Vector3v
, doubleangle
);Rotates a given
Vector3
by an
in radians in counter clockwise direction around the yaxis.angle
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
(Vector3v
, doubleangle
);Rotates a given
Vector3
by an
in radians in counter clockwise direction around the zaxis.angle
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 Ndimensional vector. This struct only works for vectors with more than 3 dimensions.
Date
September 28, 2021
Examples
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 withdim
0.0
s.Date
September 28, 2021
Parameters
dim
is the number of dimensions.
Return Value
A
Vector!dim
filled withdim
0.0
s. 
Declaration
pure @safe Vector!dim
add
(size_t dim)(Vector!dimv1
, Vector!dimv2
);Adds two
Vector!dim
with the same dimensions component wise.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
andv1
.v2

Declaration
pure @safe Vector!dim
scale
(size_t dim)(Vector!dimv
, doublescalar
);Scales a vector
by a given numberv
.scalar
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!dimv
);Calculates the magnitude (or length) of
.v
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!dimv
);Calculates the normalized version of
.v
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!dimv1
, Vector!dimv2
);Calculates the
dot
product of
andv1
.v2
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 thedot
product of
andv1
.v2

Declaration
pure @safe double
angle
(size_t dim)(Vector!dimv1
, Vector!dimv2
);Calculates the
angle
between
andv1
.v2
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 theangle
between
and 'v1
v2
'. 
Declaration
pure @safe Vector!(dim + 1)
upgrade
(size_t dim)(Vector!dimv
);Adds a dimension to
, making it av
Vector!(dim + 1)
. The new dimension has default value 0.0.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 additional0.0
as a component.