Crate geologic

Source
Expand description

Mathematical and geometrical abstractions with a focus on ergonomics.

§Disclaimer

This library is a work in progress still, there may be breaking changes between versions.

If you want a missing feature or want to report a bug, please create an issue on GitHub.

§Examples

// Import the prelude for convenience
use geologic::*;

let position = point!(0i32, 40);
let size = size!(5; 2);

// Derive a Bounds2D from a position and size.
let bounds = position.with_size(size);

// Translate the bounds with an offset
let moved_bounds = bounds + offset!(3, 5);

// Resize the bounds up with a size
let enlarged_bounds = moved_bounds + size!(10, 10);
assert_eq!(enlarged_bounds, bounds!(3, 45, 15, 15));

// We can also use tuples and types interchangeably for operations like these
let moved_bounds = bounds.with_position((0, 0));
assert_eq!(moved_bounds, bounds!(0, 0, 5, 5))

Re-exports§

Modules§

  • Helper macros for instantiating different kinds of algebraic types.

Macros§

  • Creates a new bounding box.
  • Creates a new offset vector.
  • Creates a new point vector.
  • Creates a new size.

Structs§

  • A two-dimensional bounding box.
  • A 2D array, representing a grid with X and Y space.
  • Marker struct for a vector used as a translation or velocity.
  • Marker struct for a vector used as a point.
  • A vector describing a two-dimensional size.
  • A generic vector with an X and Y component.

Traits§

Type Aliases§

  • A two-dimensional vector representing an offset.
  • A two-dimensional vector representing a point.