Crate emath

source ·
Expand description

Opinionated 2D math library for building GUIs.

Includes vectors, positions, rectangles etc.

Conventions (unless otherwise specified):

  • All angles are in radians
  • X+ is right and Y+ is down.
  • (0,0) is left top.
  • Dimension order is always x y

§Integrating with other math libraries.

emath does not strive to become a general purpose or all-powerful math library.

For that, use something else (glam, nalgebra, …) and enable the mint feature flag in emath to enable implicit conversion to/from emath.

§Feature flags

Re-exports§

  • pub use self::align::Align;
  • pub use self::align::Align2;

Modules§

Macros§

Structs§

  • This struct tracks recent values of some time series.
  • Wraps a floating-point value to add total order and hash. Possible types for T are f32 and f64.
  • A position on screen.
  • Inclusive range of floats, i.e. min..=max, but more ergonomic than RangeInclusive.
  • A rectangular region of space.
  • Linearly transforms positions from one Rect to another.
  • Represents a rotation in the 2D plane.
  • Linearly transforms positions via a translation, then a scaling.
  • A vector has a direction and length. A Vec2 is often used to represent a size.
  • Two bools, one for each axis (X and Y).

Traits§

  • Extension trait to provide ord() method.
  • Extends f32, Vec2 etc with at_least and at_most as aliases for max and min.
  • Implemented for all builtin numeric types
  • Helper trait to implement lerp and remap.
  • Helper trait to implement lerp and remap.

Functions§