Skip to main content

cgmath/
lib.rs

1// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
2// refer to the Cargo.toml file at the top-level directory of this distribution.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//     http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! A low-dimensional linear algebra library, targeted at computer graphics.
17//!
18//! # Trait overview
19//!
20//! In order to make a clean, composable API, we divide operations into traits
21//! that are roughly based on mathematical properties. The main ones that we
22//! concern ourselves with are listed below:
23//!
24//! - `VectorSpace`: Specifies the main operators for vectors, quaternions, and
25//!   matrices.
26//! - `MetricSpace`: For types that have a distance function implemented.
27//! - `InnerSpace`: For types that have a dot (or inner) product - ie. vectors or
28//!   quaternions. This also allows for the definition of operations that are
29//!   based on the dot product, like finding the magnitude or normalizing.
30//! - `EuclideanSpace`: Points in euclidean space, with an associated space of
31//!   displacement vectors.
32//! - `Matrix`: Common operations for matrices of arbitrary dimensions.
33//! - `SquareMatrix`: A special trait for matrices where the number of columns
34//!   equal the number of rows.
35//!
36//! Other traits are included for practical convenience, for example:
37//!
38//! - `Array`: For contiguous, indexable arrays of elements, specifically
39//!   vectors.
40//! - `ElementWise`: For element-wise addition, subtraction, multiplication,
41//!   division, and remainder operations.
42//!
43//! # The prelude
44//!
45//! Importing each trait individually can become a chore, so we provide a
46//! `prelude` module to allow you to import the main traits all at once. For
47//! example:
48//!
49//! ```rust
50//! use cgmath::prelude::*;
51//! ```
52
53#![cfg_attr(feature = "simd", feature(specialization))]
54
55#[macro_use]
56extern crate approx;
57
58#[cfg(feature = "mint")]
59pub extern crate mint;
60
61pub extern crate num_traits;
62#[cfg(feature = "rand")]
63extern crate rand;
64
65#[cfg(feature = "serde")]
66#[macro_use]
67extern crate serde;
68
69// Re-exports
70
71pub use approx::*;
72pub use num::*;
73pub use structure::*;
74
75pub use matrix::{Matrix2, Matrix3, Matrix4};
76pub use quaternion::Quaternion;
77pub use vector::{dot, vec1, vec2, vec3, vec4, Vector1, Vector2, Vector3, Vector4};
78
79pub use angle::{Deg, Rad};
80pub use euler::Euler;
81pub use point::{point1, point2, point3, Point1, Point2, Point3};
82pub use rotation::*;
83pub use transform::*;
84
85pub use projection::*;
86
87// Modules
88
89pub mod conv;
90pub mod prelude;
91
92mod macros;
93
94mod num;
95mod structure;
96
97mod matrix;
98mod quaternion;
99
100mod vector;
101
102mod angle;
103mod euler;
104mod point;
105mod rotation;
106mod transform;
107
108mod projection;