88 releases

0.22.11 Aug 28, 2024
0.22.10 May 21, 2024
0.22.9 Mar 25, 2023
0.22.7 Apr 4, 2022
0.1.5 Jul 23, 2015

#7 in Math

Download history 66263/week @ 2024-07-18 66141/week @ 2024-07-25 60337/week @ 2024-08-01 75956/week @ 2024-08-08 65187/week @ 2024-08-15 71935/week @ 2024-08-22 87272/week @ 2024-08-29 74375/week @ 2024-09-05 66729/week @ 2024-09-12 69688/week @ 2024-09-19 76501/week @ 2024-09-26 78871/week @ 2024-10-03 69663/week @ 2024-10-10 72373/week @ 2024-10-17 70542/week @ 2024-10-24 73692/week @ 2024-10-31

299,776 downloads per month
Used in 1,243 crates (152 directly)

MIT/Apache

500KB
12K 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

~94–440KB