Crate lowdim

source ·
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

Structs

Enums

  • The symmetries of discrete 2d vectors.

Traits

  • Required traits and operations for integers.
  • Required traits and operations for matrices.
  • Required arithmetic operations for matrices.
  • Required traits and operations for vectors.
  • Required arithmetic operations for vectors.

Functions

  • Creates a 2d bounding box from ranges of x and y coordinates.
  • Creates a 3d bounding box from ranges of x, y and z coordinates.
  • Creates a 4d bounding box from ranges of x, y, z and w coordinates.
  • Creates a 2d point.
  • Creates a 3d point.
  • Creates a 4d point.
  • Creates a 2d vector.
  • Creates a 3d vector.
  • Creates a 4d vector.

Type Aliases