65 releases

0.20.3 Oct 8, 2019
0.20.1 Jul 23, 2019
0.19.9 Jun 11, 2019
0.19.7 Mar 29, 2019
0.1.5 Jul 23, 2015

#11 in Math

Download history 4975/week @ 2019-06-25 4945/week @ 2019-07-02 3693/week @ 2019-07-09 3958/week @ 2019-07-16 4925/week @ 2019-07-23 4990/week @ 2019-07-30 4715/week @ 2019-08-06 4836/week @ 2019-08-13 5063/week @ 2019-08-20 4156/week @ 2019-08-27 5278/week @ 2019-09-03 5472/week @ 2019-09-10 4775/week @ 2019-09-17 6002/week @ 2019-09-24 7328/week @ 2019-10-01

21,379 downloads per month
Used in 114 crates (34 directly)

MIT/Apache

370KB
9K SLoC

euclid

This is a small library for geometric types with a focus on 2d graphics and layout.


lib.rs:

A collection of strongly typed math tools for computer graphics with an inclination towards 2d graphics and layout.

All types are generic over the scalar type of their component (f32, i32, etc.), and tagged with a generic Unit parameter which is useful to prevent mixing values from different spaces. For example it should not be legal to translate a screen-space position by a world-space vector and this can be expressed using the generic Unit parameter.

This unit system is not mandatory and all structures have an alias with the default unit: UnknownUnit. for example default::Point2D<T> is equivalent to Point2D<T, UnknownUnit>. Client code typically creates a set of aliases for each type and doesn't need to deal with the specifics of typed units further. For example:

use euclid::*;
pub struct ScreenSpace;
pub type ScreenPoint = Point2D<f32, ScreenSpace>;
pub type ScreenSize = Size2D<f32, ScreenSpace>;
pub struct WorldSpace;
pub type WorldPoint = Point3D<f32, WorldSpace>;
pub type ProjectionMatrix = Transform3D<f32, WorldSpace, ScreenSpace>;
// etc...

All euclid types are marked #[repr(C)] in order to facilitate exposing them to foreign function interfaces (provided the underlying scalar type is also repr(C)).

A set of aliases for all types, tagged with the default unknown unit.

Dependencies