# dvec 0.0.6

Library for extremely lightweight vector and matrix operations.

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

## dvec - Easy linear algebra for D

dvec is a library that offers vector and matrix data structures and functions in a way that's intuitive, easy to use, tested, and well-documented. It takes advantage of the D language's advanced templating system and compile-time code-generation to help optimize performance and type safety.

dvec offers the basic linear algebra primitives:

• Vectors
• Matrices

Each of these can be of any desired integer size (within the limits of your system). For example, `Vec!(float, 5) v;` defines a 5-dimensional floating-point vector, and `Mat!(int, 2, 3) m;` defines a 2x3 (2 rows by 3 columns) integer matrix. However, this can get to be a bit tedious, so we've included the most common vectors and matrices as aliases for you:

• 2, 3, and 4-dimensional vectors of float, double, and int types: `Vec3d`, `Vec2i`, and `Vec4f`, for example.
• 2, 3, and 4-dimensional square matrices of float, double, and int types: `Mat2f`, `Mat3i`, and `Mat4d`, for example.

Each primitive is a simple struct with a fully transparent internal structure, and implements all the basic arithmetic operators, so you can do things like this easily:

``````Vec3f v = Vec3f(1f, 2f, 3f) * 5 - Vec3f(0.5f);
// v.data == [4.5f, 9.5f, 14.5f]
``````

Besides the `toString()` methods, no parts of this library make use of the GC, and are thus `@nogc` compatible.

#### Vectors

• Any floating-point (float, double) vector supports the `norm()` method, to normalize the vector to a unit vector of length 1.
• Any floating-point (float, double) 2-dimensional vector supports the `toPolar()` and `toCartesian()` methods, so that the vector can be treated as polar or cartesian coordinates and converted between the two.
• Any floating-point (float, double) 3-dimensional vector supports the `cross()` method for computing the cross product with another 3-dimensional vector.

#### Matrices

• Square matrices (NxM matrices where N = M) support a variety of additional methods that are useful for linear algebra, like `det()` (determinant), `inv()` (inverse), and so on.
• 3x3 matrices support linear transformation methods in 2 dimensions, like translation, rotation, skew, and scaling.
• 4x4 matrices support linear transformation methods in 3 dimensions.

A lot of effort has gone into making sure everything in this library is well-documented and explained well. If you find that documentation is missing or insufficient for a certain part, please make an issue on GitHub!

• Registered by Andrew Lalis
• 0.0.6 released 2 years ago
• andrewlalis/dvec
• MIT
Authors:
• Andrew Lalis
Dependencies:
none
Versions:
 0.0.7 2022-Oct-26 0.0.6 2022-Oct-25 0.0.5 2022-Oct-24 0.0.4 2022-Apr-10 0.0.3 2022-Apr-06