std/linear
Vectors, matrices, quaternions and angles, generic over the scalar they are made of.
There is one vector type per width and not two: Vector2 is the Float vector, Vector2<Int> the pixel or grid
vector, and Vector2<Fixed> the deterministic one. What each of them can do is decided by the scalar's bound -
everything that is arithmetic alone lives under Numeric, and everything that needs a square root or an angle lives
under Real (std/number).
The package is pure value arithmetic. It knows nothing about entities, rendering or files, and the packages that do build on it instead.
Modules
std/linear/angle[Angle], the wrapper that keeps a quarter turn written as90from being read as90radians.std/linear/fixed[Fixed], the deterministic scalar: a whole number of1/65536parts, with every operation - the square root and the trigonometry included - computed in integer arithmetic alone.std/linear/matrix2[Matrix2], the 2x2 matrix: the linear part of a transformation in the plane - rotation, scale, shear - without a translation.std/linear/matrix3[Matrix3], the 3x3 matrix: a linear transformation of space, and at the same time the affine transformation of the plane - rotation, scale, shear and a translation - that a 2D scene graph is built out of.std/linear/matrix4[Matrix4], the 4x4 matrix: the affine transformation of space - rotation, scale, shear and a translation - that a scene graph is built out of.std/linear/quaternion[Quaternion], a rotation of space that composes and interpolates without shearing and without the gimbal lock that three angles in a row have.std/linear/vector2[Vector2], the two-component vector, and the three layers of members its scalar decides.std/linear/vector3[Vector3], the three-component vector, layered by its scalar's bound exactly as [Vector2] is.std/linear/vector4[Vector4], the four-component vector: a homogeneous point or direction, and the column aMatrix4is made of.
Everything
- type
AngleA rotation, held in radians and constructed by the unit it is written in. - extend
Angle<Scalar>The three turns that are worth a name, for every scalar: its own [Real.pi] and [Real.tau]. - type
FixedA number held as a whole number of1/65536parts: the Q16.16 fixed-point scalar, and the only [Real] whose answers are the same bits on every platform and out of every back end. - extend
Fixed with Power<Int64>A whole power, by squaring: every step is a multiplication ofFixedvalues, so the result is the same bits everywhere, and a negative exponent is one over the positive power. - extend
Fixed with From<Int64>A whole number is exact as aFixedwhile its magnitude stays below2^47; above that the multiplication panics. - type
Matrix2A linear transformation of the plane, held as the two vectors its basis lands on. - extend
Matrix2<Scalar> with NegateEvery cell turned around. - extend
Matrix2<Scalar>What an angle and a division buy: rotations and the way back. - extend
Matrix2<Scalar> with Power<Int64>A whole power: the transformation applied that many times over. - type
Matrix3A linear transformation of space, held as the three vectors its basis lands on - or an affine transformation of the plane, where the third column is the translation. - extend
Matrix3<Scalar> with NegateEvery cell turned around. - extend
Matrix3<Scalar>What an angle and a division buy: the three rotations, and the way back. - extend
Matrix3<Scalar> with Power<Int64>A whole power: the transformation applied that many times over. - type
Matrix4An affine transformation of space, held as the four vectors its homogeneous basis lands on. - extend
Matrix4<Scalar> with NegateEvery cell turned around. - extend
Matrix4<Scalar>What a division buys: the inverse of an affine transformation, and the general one. - extend
Matrix4<Scalar> with Power<Int64>A whole power: the transformation applied that many times over. - type
QuaternionA rotation of space, as four numbers. - type
Vector2A point, a direction or a size in the plane, over whatever scalar the program counts in. - extend
Vector2<Scalar> with NegateA vector of a signed scalar can be turned around, and that is what a direction needs. - extend
Vector2<Scalar>What a sign buys: a distance that needs no root, and the quarter turn that needs no trigonometry. - extend
Vector2<Scalar>What a root and an angle buy: lengths, directions and interpolation. - extend
Vector2<Float>The float vector: the three ways down to a grid. - extend
Vector2<Int>The grid vector: the two ways up to a scalar that has fractions. - type
Vector3A point, a direction or a size in space, over whatever scalar the program counts in. - extend
Vector3<Scalar> with NegateA vector of a signed scalar can be turned around. - extend
Vector3<Scalar>What a sign buys: a distance along the axes, without a root. - extend
Vector3<Scalar>What a root and an angle buy: lengths, directions and interpolation. - extend
Vector3<Float>The float vector: the three ways down to a grid. - extend
Vector3<Int>The grid vector: the two ways up to a scalar that has fractions. - type
Vector4Four components, over whatever scalar the program counts in: the homogeneous form of a point (wone) or of a direction (wzero), and a colour with an alpha where a program wants one. - extend
Vector4<Scalar> with NegateA vector of a signed scalar can be turned around. - extend
Vector4<Scalar>Every component without its sign. - extend
Vector4<Scalar>What a root buys: a length, a direction and the way out of homogeneous coordinates. - extend
Vector4<Int>The grid vector: the way up to a scalar that has fractions.