Expand description
Affine geometry for discrete 2d, 3d and 4d worlds.
Provides vectors, matrices, points and more to simplify programming for 2d to 4d worlds. Features include:
- Vector and point arithmetic
- Bounding boxes and iterators over the points inside them
- Arrays indexed by points in bounding boxes
- Taxicab (L1) and maximum (L∞) metrics
- Iterators over orthogonal and king’s move neighbourhoods
- Rotations and reflections (currently only implemented for 2d)
This was originally motivated by Advent of Code (yes, Santa’s elves use the 4th dimension, for example for time travel).
§Crate Status
Experimental
§Limitations
- Rotations and reflections are only implemented for the 2d case.
§Crate Feature Flags
random
- Off by default.
- Adds a dependency to the
rand
crate. - Adds the method
random_point
to generate random points in a bounding box.
Modules§
- affine_
transformation - Affine transformations for n-dimensional discrete spaces.
- array
- n-dimensional arrays indexed by points in a bounding box.
- bbox
- n-dimensional bounding boxes.
- integer
- Contains traits defining required properties of the underlying integer types.
- matrix
- Traits for matrices.
- matrix2d
- 2d matrices.
- matrix3d
- 3d matrices.
- matrix4d
- 4d matrices.
- point
- Points in the affine space.
- sym2d
- Symmetries of 2d vectors.
- vec2d
- 2d vectors.
- vec3d
- 3d vectors.
- vec4d
- 4d vectors.
- vector
- Traits for vectors.
Structs§
- Affine
Transformation - An affine transformation.
- Array
- An array indexed by points in a bounding box.
- BBox
- A bounding box.
- Matrix2d
- A 2d discrete matrix.
- Matrix3d
- A 3d discrete matrix.
- Matrix4d
- A 4d discrete matrix.
- Point
- A point in a discrete space.
- Vec2d
- A 2d discrete vector.
- Vec3d
- A 3d discrete vector.
- Vec4d
- A 4d discrete vector.
Enums§
- Sym2d
- The symmetries of discrete 2d vectors.
Traits§
- Integer
- Required traits and operations for integers.
- Matrix
- Required traits and operations for matrices.
- Matrix
Ops - Required arithmetic operations for matrices.
- Vector
- Required traits and operations for vectors.
- Vector
Ops - Required arithmetic operations for vectors.
Functions§
- bb2d
- Creates a 2d bounding box from ranges of x and y coordinates.
- bb3d
- Creates a 3d bounding box from ranges of x, y and z coordinates.
- bb4d
- Creates a 4d bounding box from ranges of x, y, z and w coordinates.
- p2d
- Creates a 2d point.
- p3d
- Creates a 3d point.
- p4d
- Creates a 4d point.
- v2d
- Creates a 2d vector.
- v3d
- Creates a 3d vector.
- v4d
- Creates a 4d vector.
Type Aliases§
- Affine
Transformation2d - A 2d affine transformation.
- Affine
Transformation3d - A 3d affine transformation.
- Affine
Transformation4d - A 4d affine transformation.
- Array2d
- A 2d array indexed by points in a bounding box.
- Array3d
- A 3d array indexed by points in a bounding box.
- Array4d
- A 4d array indexed by points in a bounding box.
- BBox2d
- A 2d bounding box.
- BBox3d
- A 3d bounding box.
- BBox4d
- A 4d bounding box.
- Point2d
- A 2d point.
- Point3d
- A 3d point.
- Point4d
- A 4d point.