#math #vector #algebra #geometry

geologic

Mathematical and geometrical abstractions with a focus on ergonomics

3 releases

0.0.3 Jul 6, 2022
0.0.2 Jul 3, 2022
0.0.1 Jun 26, 2022

#458 in Math

25 downloads per month

MIT license

41KB
926 lines

Geologic

This is a work in progress.


lib.rs:

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))

Dependencies

~155KB