// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![cfg_attr(not(test), no_std)] //! 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``` is equivalent to ```Point2D```. //! 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: //! //! ```rust //! use euclid::*; //! pub struct ScreenSpace; //! pub type ScreenPoint = Point2D; //! pub type ScreenSize = Size2D; //! pub struct WorldSpace; //! pub type WorldPoint = Point3D; //! pub type ProjectionMatrix = Transform3D; //! // 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)`). //! #![deny(unconditional_recursion)] pub use crate::angle::Angle; pub use crate::box2d::Box2D; pub use crate::homogen::HomogeneousVector; pub use crate::length::Length; pub use crate::point::{point2, point3, Point2D, Point3D}; pub use crate::scale::Scale; pub use crate::transform2d::Transform2D; pub use crate::transform3d::Transform3D; pub use crate::vector::{bvec2, bvec3, BoolVector2D, BoolVector3D}; pub use crate::vector::{vec2, vec3, Vector2D, Vector3D}; pub use crate::box3d::{box3d, Box3D}; pub use crate::rect::{rect, Rect}; pub use crate::rigid::RigidTransform3D; pub use crate::rotation::{Rotation2D, Rotation3D}; pub use crate::side_offsets::SideOffsets2D; pub use crate::size::{size2, size3, Size2D, Size3D}; pub use crate::translation::{Translation2D, Translation3D}; pub use crate::trig::Trig; #[macro_use] mod macros; mod angle; pub mod approxeq; pub mod approxord; mod box2d; mod box3d; mod homogen; mod length; pub mod num; mod point; mod rect; mod rigid; mod rotation; mod scale; mod side_offsets; mod size; mod transform2d; mod transform3d; mod translation; mod trig; mod vector; /// The default unit. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct UnknownUnit; pub mod default { //! A set of aliases for all types, tagged with the default unknown unit. use super::UnknownUnit; pub type Length = super::Length; pub type Point2D = super::Point2D; pub type Point3D = super::Point3D; pub type Vector2D = super::Vector2D; pub type Vector3D = super::Vector3D; pub type HomogeneousVector = super::HomogeneousVector; pub type Size2D = super::Size2D; pub type Size3D = super::Size3D; pub type Rect = super::Rect; pub type Box2D = super::Box2D; pub type Box3D = super::Box3D; pub type SideOffsets2D = super::SideOffsets2D; pub type Transform2D = super::Transform2D; pub type Transform3D = super::Transform3D; pub type Rotation2D = super::Rotation2D; pub type Rotation3D = super::Rotation3D; pub type Translation2D = super::Translation2D; pub type Translation3D = super::Translation3D; pub type Scale = super::Scale; pub type RigidTransform3D = super::RigidTransform3D; }