dvec 0.0.7
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 welldocumented. It takes advantage of the D language's advanced templating system and compiletime codegeneration 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 5dimensional floatingpoint 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 4dimensional vectors of float, double, and int types:
Vec3d
,Vec2i
, andVec4f
, for example.  2, 3, and 4dimensional square matrices of float, double, and int types:
Mat2f
,Mat3i
, andMat4d
, 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
Vectors are simply a fixedsize list of numerical elements, which implement a lot of mathematical operations that are useful in linear algebra.
The values of a vector can be accessed in the following ways:
 By index:
v[1]
gets the second element in vectorv
.  By name:
v.x, v.y, v.z, v.w
gets the first, second, third, or fourth element of a vector, respectively.  By the internal data:
v.data
gets the internal array.
Casting
You can cast vectors of different types and sizes using D's standard cast(type)
syntax. Note that the individual elements are casted using cast
as well, and that may result in data loss if you, for example, cast from a floatingpoint to integer vector. If you cast to a vector with a different size, the following rules apply:
 If the new vector type is smaller, extra elements are truncated.
 If the new vector type is larger, any missing elements are initialized to zero.
Specialization
Certain vector types get access to extra special functions:
 Any floatingpoint (float, double) vector supports the
norm()
method, to normalize the vector to a unit vector of length 1.  Any floatingpoint (float, double) 2dimensional vector supports the
toPolar()
andtoCartesian()
methods, so that the vector can be treated as polar or cartesian coordinates and converted between the two.  Any floatingpoint (float, double) 3dimensional vector supports the
cross()
method for computing the cross product with another 3dimensional vector.
Matrices
Certain matrix types get access to extra special functions:
 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.
For more information, please see dub project page and its associated documentation.
A lot of effort has gone into making sure everything in this library is welldocumented 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.7 released 2 years ago
 andrewlalis/dvec
 MIT
 Copyright © 2022, Andrew Lalis
 Authors:
 Dependencies:
 none
 Versions:

0.0.7 2022Oct26 0.0.6 2022Oct25 0.0.5 2022Oct24 0.0.4 2022Apr10 0.0.3 2022Apr06  Download Stats:


0 downloads today

0 downloads this week

2 downloads this month

34 downloads total

 Score:
 1.0
 Short URL:
 dvec.dub.pm