2014-05-26 17:10:04 +00:00
|
|
|
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
2015-03-14 02:49:46 +00:00
|
|
|
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
2013-07-11 23:18:05 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-04-09 03:50:39 +00:00
|
|
|
//! A low-dimensional linear algebra library, targeted at computer graphics.
|
2014-05-25 20:52:01 +00:00
|
|
|
//!
|
2016-04-09 03:50:39 +00:00
|
|
|
//! # Trait overview
|
2014-05-25 21:35:46 +00:00
|
|
|
//!
|
2016-04-09 03:50:39 +00:00
|
|
|
//! In order to make a clean, composable API, we divide operations into traits
|
|
|
|
//! that are roughly based on mathematical properties. The main ones that we
|
|
|
|
//! concern ourselves with are listed below:
|
|
|
|
//!
|
|
|
|
//! - `VectorSpace`: Specifies the main operators for vectors, quaternions, and
|
2016-04-23 09:52:37 +00:00
|
|
|
//! matrices.
|
|
|
|
//! - `MetricSpace`: For types that have a distance function implemented.
|
2016-04-09 03:50:39 +00:00
|
|
|
//! - `InnerSpace`: For types that have a dot (or inner) product - ie. vectors or
|
2016-04-23 09:52:37 +00:00
|
|
|
//! quaternions. This also allows for the definition of operations that are
|
|
|
|
//! based on the dot product, like finding the magnitude or normalizing.
|
2016-04-09 03:50:39 +00:00
|
|
|
//! - `EuclideanSpace`: Points in euclidean space, with an associated space of
|
|
|
|
//! displacement vectors.
|
|
|
|
//! - `Matrix`: Common operations for matrices of arbitrary dimensions.
|
|
|
|
//! - `SquareMatrix`: A special trait for matrices where the number of columns
|
|
|
|
//! equal the number of rows.
|
|
|
|
//!
|
|
|
|
//! Other traits are included for practical convenience, for example:
|
|
|
|
//!
|
|
|
|
//! - `Array`: For contiguous, indexable arrays of elements, specifically
|
|
|
|
//! vectors.
|
|
|
|
//! - `ElementWise`: For element-wise addition, subtraction, multiplication,
|
|
|
|
//! division, and remainder operations.
|
|
|
|
//!
|
|
|
|
//! # The prelude
|
|
|
|
//!
|
|
|
|
//! Importing each trait individually can become a chore, so we provide a
|
|
|
|
//! `prelude` module to allow you to import the main trait all at once. For
|
|
|
|
//! example:
|
|
|
|
//!
|
|
|
|
//! ```rust
|
|
|
|
//! use cgmath::prelude::*;
|
|
|
|
//! ```
|
2014-05-25 20:52:01 +00:00
|
|
|
|
2016-05-10 11:55:20 +00:00
|
|
|
pub extern crate num_traits;
|
2015-03-15 02:53:57 +00:00
|
|
|
extern crate rand;
|
2014-08-23 12:34:33 +00:00
|
|
|
|
2016-05-15 12:48:57 +00:00
|
|
|
#[cfg(feature = "rustc-serialize")]
|
|
|
|
extern crate rustc_serialize;
|
|
|
|
|
2014-08-16 04:51:09 +00:00
|
|
|
// Re-exports
|
|
|
|
|
2016-04-19 10:51:40 +00:00
|
|
|
pub use approx::*;
|
|
|
|
pub use num::*;
|
|
|
|
pub use structure::*;
|
|
|
|
|
|
|
|
pub use matrix::{Matrix2, Matrix3, Matrix4};
|
|
|
|
pub use quaternion::Quaternion;
|
2016-04-24 22:59:33 +00:00
|
|
|
pub use vector::{Vector1, Vector2, Vector3, Vector4, dot, vec1, vec2, vec3, vec4};
|
2015-03-01 06:29:47 +00:00
|
|
|
|
2016-04-19 10:51:40 +00:00
|
|
|
pub use angle::{Deg, Rad, deg, rad};
|
2016-04-17 04:33:06 +00:00
|
|
|
pub use euler::Euler;
|
2016-04-24 22:59:33 +00:00
|
|
|
pub use point::{Point1, Point2, Point3};
|
2015-03-01 06:29:47 +00:00
|
|
|
pub use rotation::*;
|
|
|
|
pub use transform::*;
|
|
|
|
|
|
|
|
pub use projection::*;
|
|
|
|
|
2014-08-16 04:51:09 +00:00
|
|
|
// Modules
|
|
|
|
|
2016-03-26 05:40:31 +00:00
|
|
|
pub mod conv;
|
2016-03-25 04:27:57 +00:00
|
|
|
pub mod prelude;
|
|
|
|
|
2015-12-12 11:17:03 +00:00
|
|
|
mod macros;
|
|
|
|
|
2016-04-19 10:51:40 +00:00
|
|
|
mod approx;
|
|
|
|
mod num;
|
|
|
|
mod structure;
|
2014-08-16 04:51:09 +00:00
|
|
|
|
|
|
|
mod matrix;
|
|
|
|
mod quaternion;
|
|
|
|
mod vector;
|
|
|
|
|
|
|
|
mod angle;
|
2016-04-17 04:33:06 +00:00
|
|
|
mod euler;
|
2014-08-16 04:51:09 +00:00
|
|
|
mod point;
|
|
|
|
mod rotation;
|
|
|
|
mod transform;
|
|
|
|
|
|
|
|
mod projection;
|