ncollide3d/
lib.rs

1/*!
2ncollide
3========
4
5**ncollide** is a 2 and 3-dimensional collision detection library written with
6the rust programming language.
7
8As its name suggests, it is generic wrt the dimension: it works with both
92-dimensional and 3-dimensional shapes.
10
11The official user guide is available [here](http://ncollide.org).
12The rustdoc documentation is available [here](http://ncollide.org/rustdoc/ncollide).
13
14## Compilation
15You will need the last stable build of the [rust compiler](http://www.rust-lang.org)
16and the official package manager: [cargo](https://github.com/rust-lang/cargo).
17
18Simply add the following to your `Cargo.toml` file:
19
20```.ignore
21[dependencies]
22ncollide2d = "0.33" # For 2D collision detection.
23ncollide3d = "0.33" # For 3D collision detection.
24```
25
26
27## Features
28- dynamic bounding volume tree based broad phase
29- ball vs. ball collision detection,
30- plane vs. any convex object collision detection.
31- collision detection between arbitrary convex objects
32- compound shapes
33- ray-casting
34- time of impact computation  for objects without rotational movement (compound vs. compound is not
35  yet implemented)
36
37And various traits for collision detectors and broad phase collision detection.
38*/
39
40#![deny(non_camel_case_types)]
41#![deny(unused_parens)]
42#![deny(non_upper_case_globals)]
43#![deny(unused_qualifications)]
44#![deny(missing_docs)]
45#![deny(unused_results)]
46#![warn(unused_imports)]
47#![allow(missing_copy_implementations)]
48#![doc(html_root_url = "http://ncollide.org/rustdoc")]
49
50#[cfg(feature = "serde")]
51#[macro_use]
52extern crate serde;
53#[macro_use]
54extern crate approx;
55#[macro_use]
56extern crate downcast_rs;
57#[macro_use]
58extern crate bitflags;
59extern crate num_traits as num;
60
61pub extern crate nalgebra as na;
62pub extern crate simba;
63
64macro_rules! try_ret {
65    ($val: expr) => {
66        try_ret!($val, ())
67    };
68    ($val: expr, $ret: expr) => {
69        if let Some(val) = $val {
70            val
71        } else {
72            return $ret;
73        }
74    };
75}
76
77const NOT_REGISTERED_ERROR: &'static str =
78    "This collision object has not been registered into a world (proxy indexes are None).";
79
80#[deprecated = "use the `pipeline` module instead."]
81pub use crate::pipeline::{broad_phase, narrow_phase, world};
82
83pub mod bounding_volume;
84pub mod interpolation;
85pub mod partitioning;
86pub mod pipeline;
87pub mod procedural;
88pub mod query;
89pub mod shape;
90pub mod transformation;
91pub mod utils;
92
93/// Compilation flags dependent aliases for mathematical types.
94#[cfg(feature = "dim3")]
95pub mod math {
96    use na::{Isometry3, Matrix3, Point3, Translation3, UnitQuaternion, Vector3, Vector6, U3, U6};
97
98    /// The dimension of the space.
99    pub const DIM: usize = 3;
100
101    /// The dimension of the ambient space.
102    pub type Dim = U3;
103
104    /// The dimension of a spatial vector.
105    pub type SpatialDim = U6;
106
107    /// The dimension of the rotations.
108    pub type AngularDim = U3;
109
110    /// The point type.
111    pub type Point<N> = Point3<N>;
112
113    /// The angular vector type.
114    pub type AngularVector<N> = Vector3<N>;
115
116    /// The vector type.
117    pub type Vector<N> = Vector3<N>;
118
119    /// The matrix type.
120    pub type Matrix<N> = Matrix3<N>;
121
122    /// The vector type with dimension `SpatialDim × 1`.
123    pub type SpatialVector<N> = Vector6<N>;
124
125    /// The orientation type.
126    pub type Orientation<N> = Vector3<N>;
127
128    /// The transformation matrix type.
129    pub type Isometry<N> = Isometry3<N>;
130
131    /// The rotation matrix type.
132    pub type Rotation<N> = UnitQuaternion<N>;
133
134    /// The translation type.
135    pub type Translation<N> = Translation3<N>;
136}
137
138/// Compilation flags dependent aliases for mathematical types.
139#[cfg(feature = "dim2")]
140pub mod math {
141    use na::{Isometry2, Matrix2, Point2, Translation2, UnitComplex, Vector1, Vector2, U2};
142
143    /// The dimension of the space.
144    pub const DIM: usize = 2;
145
146    /// The dimension of the ambiant space.
147    pub type Dim = U2;
148
149    /// The point type.
150    pub type Point<N> = Point2<N>;
151
152    /// The vector type.
153    pub type Vector<N> = Vector2<N>;
154
155    /// The matrix type.
156    pub type Matrix<N> = Matrix2<N>;
157
158    /// The orientation type.
159    pub type Orientation<N> = Vector1<N>;
160
161    /// The transformation matrix type.
162    pub type Isometry<N> = Isometry2<N>;
163
164    /// The rotation matrix type.
165    pub type Rotation<N> = UnitComplex<N>;
166
167    /// The translation type.
168    pub type Translation<N> = Translation2<N>;
169}