Make serde optional behind the "serde-serialize" feature.

This commit is contained in:
Sébastien Crozet 2017-02-15 22:04:34 +01:00
parent 896ad19dd0
commit 42b48563be
24 changed files with 284 additions and 36 deletions

View File

@ -3,5 +3,7 @@ language: rust
script: script:
- rustc --version - rustc --version
- cargo --version - cargo --version
- cargo build --verbose
- cargo build --verbose --features arbitrary - cargo build --verbose --features arbitrary
- cargo test --verbose --features arbitrary - cargo build --verbose --features serde-serialize
- cargo test --verbose --features arbitrary serde-serialize

View File

@ -10,6 +10,8 @@ overview of all the added/modified features.
This version is a major rewrite of the library. Major changes are: This version is a major rewrite of the library. Major changes are:
* Algebraic traits are now defined by the [alga](https://crates.io/crates/alga) crate. * Algebraic traits are now defined by the [alga](https://crates.io/crates/alga) crate.
All other mathematical traits, except `Axpy` have been removed from
**nalgebra**.
* Methods are now preferred to free functions because they do not require any * Methods are now preferred to free functions because they do not require any
trait to be used any more. trait to be used any more.
* Most algebraic entities can be parametrized by type-level integers * Most algebraic entities can be parametrized by type-level integers
@ -19,7 +21,8 @@ This version is a major rewrite of the library. Major changes are:
* More transformation types have been added: unit-sized complex numbers (for * More transformation types have been added: unit-sized complex numbers (for
2D rotations), affine/projective/general transformations with `Affine2/3`, 2D rotations), affine/projective/general transformations with `Affine2/3`,
`Projective2/3`, and `Transform2/3`. `Projective2/3`, and `Transform2/3`.
* Serde serialization is now supported instead of `rustc_serialize`. * Serde serialization is now supported instead of `rustc_serialize`. Enable
it with the `serde-serialize` feature.
* Matrix **slices** are now implemented. * Matrix **slices** are now implemented.
### Added ### Added

View File

@ -17,6 +17,7 @@ path = "src/lib.rs"
[features] [features]
arbitrary = [ "quickcheck" ] arbitrary = [ "quickcheck" ]
serde-serialize = [ "serde", "serde_derive" ]
[dependencies] [dependencies]
typenum = "1.4" typenum = "1.4"
@ -25,9 +26,9 @@ rand = "0.3"
num-traits = "0.1" num-traits = "0.1"
num-complex = "0.1" num-complex = "0.1"
approx = "0.1" approx = "0.1"
alga = "0.4" alga = "0.5"
serde = "0.9" serde = { version = "0.9", optional = true }
serde_derive = "0.9" serde_derive = { version = "0.9", optional = true }
# clippy = "*" # clippy = "*"
[dependencies.quickcheck] [dependencies.quickcheck]

View File

@ -1,11 +1,11 @@
all: all:
CARGO_INCREMENTAL=1 cargo build --features "arbitrary" CARGO_INCREMENTAL=1 cargo build --features "arbitrary serde-serialize"
doc: doc:
CARGO_INCREMENTAL=1 cargo doc --no-deps CARGO_INCREMENTAL=1 cargo doc --no-deps --features "arbitrary serde-serialize"
bench: bench:
cargo bench cargo bench
test: test:
CARGO_INCREMENTAL=1 cargo test --features "arbitrary" CARGO_INCREMENTAL=1 cargo test --features "arbitrary serde-serialize"

View File

@ -14,7 +14,7 @@
</p> </p>
<p align = "center"> <p align = "center">
<strong> <strong>
<a href="http://nalgebra.org">Users guide</a> | <a href="http://nalgebra.org/rustdoc/nalgebra/index.html">Documentation</a> | <a href="http://users.nphysics.org">Forum</a> <a href="http://nalgebra.org">Users guide</a> | <a href="http://nalgebra.org/rustdoc/nalgebra/index.html">Documentation</a> | <a href="http://users.nphysics.org/c/nalgebra">Forum</a>
</strong> </strong>
</p> </p>

View File

@ -23,7 +23,8 @@ macro_rules! coords_impl(
/// Data structure used to provide access to matrix and vector coordinates with the dot /// Data structure used to provide access to matrix and vector coordinates with the dot
/// notation, e.g., `v.x` is the same as `v[0]` for a vector. /// notation, e.g., `v.x` is the same as `v[0]` for a vector.
#[repr(C)] #[repr(C)]
#[derive(Eq, PartialEq, Clone, Hash, Debug, Copy, Serialize, Deserialize)] #[derive(Eq, PartialEq, Clone, Hash, Debug, Copy)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct $T<N: Scalar> { pub struct $T<N: Scalar> {
$(pub $comps: N),* $(pub $comps: N),*
} }

View File

@ -8,7 +8,8 @@ use std::ops::{Add, Sub, Mul, Div};
use typenum::{self, Unsigned, UInt, B1, Bit, UTerm, Sum, Prod, Diff, Quot}; use typenum::{self, Unsigned, UInt, B1, Bit, UTerm, Sum, Prod, Diff, Quot};
/// Dim of dynamically-sized algebraic entities. /// Dim of dynamically-sized algebraic entities.
#[derive(Clone, Copy, Eq, PartialEq, Debug, Serialize, Deserialize)] #[derive(Clone, Copy, Eq, PartialEq, Debug)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct Dynamic { pub struct Dynamic {
value: usize value: usize
} }
@ -161,7 +162,8 @@ pub trait NamedDim: Sized + Any + Unsigned {
type Name: DimName<Value = Self>; type Name: DimName<Value = Self>;
} }
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct U1; pub struct U1;
impl Dim for U1 { impl Dim for U1 {
@ -197,7 +199,8 @@ impl NamedDim for typenum::U1{
macro_rules! named_dimension( macro_rules! named_dimension(
($($D: ident),* $(,)*) => {$( ($($D: ident),* $(,)*) => {$(
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct $D; pub struct $D;
impl Dim for $D { impl Dim for $D {

View File

@ -79,13 +79,14 @@ Matrix<NNew, R, C, <<S as Storage<NOld, R, C>>::Alloc as Allocator<NNew, R, C>>:
/// dynamically-sized column vector should be represented as a `Matrix<N, Dynamic, U1, S>` (given /// dynamically-sized column vector should be represented as a `Matrix<N, Dynamic, U1, S>` (given
/// some concrete types for `N` and a compatible data storage type `S`). /// some concrete types for `N` and a compatible data storage type `S`).
#[repr(C)] #[repr(C)]
#[derive(Serialize, Deserialize, Hash, Debug, Clone, Copy)] #[derive(Hash, Debug, Clone, Copy)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct Matrix<N: Scalar, R: Dim, C: Dim, S> { pub struct Matrix<N: Scalar, R: Dim, C: Dim, S> {
/// The data storage that contains all the matrix components and informations about its number /// The data storage that contains all the matrix components and informations about its number
/// of rows and column (if needed). /// of rows and column (if needed).
pub data: S, pub data: S,
#[serde(skip_serializing, skip_deserializing)] #[cfg_attr(feature = "serde-serialize", serde(skip_serializing, skip_deserializing))]
_phantoms: PhantomData<(N, R, C)> _phantoms: PhantomData<(N, R, C)>
} }

View File

@ -1,11 +1,17 @@
use std::mem;
use std::marker::PhantomData;
use std::ops::{Deref, DerefMut, Mul}; use std::ops::{Deref, DerefMut, Mul};
use std::fmt::{self, Debug, Formatter}; use std::fmt::{self, Debug, Formatter};
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
#[cfg(feature = "serde-serialize")]
use serde::{Serialize, Serializer, Deserialize, Deserializer}; use serde::{Serialize, Serializer, Deserialize, Deserializer};
#[cfg(feature = "serde-serialize")]
use serde::ser::SerializeSeq; use serde::ser::SerializeSeq;
#[cfg(feature = "serde-serialize")]
use serde::de::{SeqVisitor, Visitor}; use serde::de::{SeqVisitor, Visitor};
#[cfg(feature = "serde-serialize")]
use std::mem;
#[cfg(feature = "serde-serialize")]
use std::marker::PhantomData;
use typenum::Prod; use typenum::Prod;
use generic_array::{ArrayLength, GenericArray}; use generic_array::{ArrayLength, GenericArray};
@ -199,6 +205,7 @@ unsafe impl<N, R, C> OwnedStorage<N, R, C> for MatrixArray<N, R, C>
* *
*/ */
// XXX: open an issue for GenericArray so that it implements serde traits? // XXX: open an issue for GenericArray so that it implements serde traits?
#[cfg(feature = "serde-serialize")]
impl<N, R, C> Serialize for MatrixArray<N, R, C> impl<N, R, C> Serialize for MatrixArray<N, R, C>
where N: Scalar + Serialize, where N: Scalar + Serialize,
R: DimName, R: DimName,
@ -220,6 +227,7 @@ where N: Scalar + Serialize,
} }
#[cfg(feature = "serde-serialize")]
impl<N, R, C> Deserialize for MatrixArray<N, R, C> impl<N, R, C> Deserialize for MatrixArray<N, R, C>
where N: Scalar + Deserialize, where N: Scalar + Deserialize,
R: DimName, R: DimName,
@ -237,11 +245,13 @@ where N: Scalar + Deserialize,
} }
#[cfg(feature = "serde-serialize")]
/// A visitor that produces a matrix array. /// A visitor that produces a matrix array.
struct MatrixArrayVisitor<N, R, C> { struct MatrixArrayVisitor<N, R, C> {
marker: PhantomData<(N, R, C)> marker: PhantomData<(N, R, C)>
} }
#[cfg(feature = "serde-serialize")]
impl<N, R, C> MatrixArrayVisitor<N, R, C> impl<N, R, C> MatrixArrayVisitor<N, R, C>
where N: Scalar, where N: Scalar,
R: DimName, R: DimName,
@ -257,6 +267,7 @@ where N: Scalar,
} }
} }
#[cfg(feature = "serde-serialize")]
impl<N, R, C> Visitor for MatrixArrayVisitor<N, R, C> impl<N, R, C> Visitor for MatrixArrayVisitor<N, R, C>
where N: Scalar + Deserialize, where N: Scalar + Deserialize,
R: DimName, R: DimName,

View File

@ -12,7 +12,8 @@ use core::default_allocator::DefaultAllocator;
*/ */
/// A Vec-based matrix data storage. It may be dynamically-sized. /// A Vec-based matrix data storage. It may be dynamically-sized.
#[repr(C)] #[repr(C)]
#[derive(Eq, Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Eq, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct MatrixVec<N, R: Dim, C: Dim> { pub struct MatrixVec<N, R: Dim, C: Dim> {
data: Vec<N>, data: Vec<N>,
nrows: R, nrows: R,

View File

@ -1,4 +1,4 @@
//! Data structures for vector and matrix computations. //! [Reexported at the root of this crate.] Data structures for vector and matrix computations.
pub mod dimension; pub mod dimension;
pub mod constraint; pub mod constraint;

View File

@ -10,7 +10,8 @@ use alga::linear::NormedSpace;
/// ///
/// Use `.as_ref()` or `.unwrap()` to obtain the undelying value by-reference or by-move. /// Use `.as_ref()` or `.unwrap()` to obtain the undelying value by-reference or by-move.
#[repr(C)] #[repr(C)]
#[derive(Eq, PartialEq, Clone, Hash, Debug, Copy, Serialize, Deserialize)] #[derive(Eq, PartialEq, Clone, Hash, Debug, Copy)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct Unit<T> { pub struct Unit<T> {
value: T value: T
} }

View File

@ -18,7 +18,8 @@ pub type OwnedIsometryBase<N, D, A, R> =
/// A direct isometry, i.e., a rotation followed by a translation. /// A direct isometry, i.e., a rotation followed by a translation.
#[repr(C)] #[repr(C)]
#[derive(Hash, Debug, Clone, Copy, Serialize, Deserialize)] #[derive(Hash, Debug, Clone, Copy)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct IsometryBase<N: Scalar, D: DimName, S, R> { pub struct IsometryBase<N: Scalar, D: DimName, S, R> {
/// The pure rotational part of this isometry. /// The pure rotational part of this isometry.
pub rotation: R, pub rotation: R,
@ -27,7 +28,7 @@ pub struct IsometryBase<N: Scalar, D: DimName, S, R> {
// One dummy private field just to prevent explicit construction. // One dummy private field just to prevent explicit construction.
#[serde(skip_serializing, skip_deserializing)] #[cfg_attr(feature = "serde-serialize", serde(skip_serializing, skip_deserializing))]
_noconstruct: PhantomData<N> _noconstruct: PhantomData<N>
} }

View File

@ -1,4 +1,5 @@
//! Data structures for points and usual transformations (rotations, isometries, etc.) //! [Reexported at the root of this crate.] Data structures for points and usual transformations
//! (rotations, isometries, etc.)
mod op_macros; mod op_macros;

View File

@ -13,7 +13,8 @@ use core::helper;
use geometry::{PointBase, OwnedPoint}; use geometry::{PointBase, OwnedPoint};
/// A 3D orthographic projection stored as an homogeneous 4x4 matrix. /// A 3D orthographic projection stored as an homogeneous 4x4 matrix.
#[derive(Debug, Clone, Copy, Serialize, Deserialize)] // FIXME: Hash #[derive(Debug, Clone, Copy)] // FIXME: Hash
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct OrthographicBase<N: Scalar, S: Storage<N, U4, U4>> { pub struct OrthographicBase<N: Scalar, S: Storage<N, U4, U4>> {
matrix: SquareMatrix<N, U4, S> matrix: SquareMatrix<N, U4, S>
} }

View File

@ -13,7 +13,8 @@ use core::helper;
use geometry::{PointBase, OwnedPoint}; use geometry::{PointBase, OwnedPoint};
/// A 3D perspective projection stored as an homogeneous 4x4 matrix. /// A 3D perspective projection stored as an homogeneous 4x4 matrix.
#[derive(Debug, Clone, Copy, Serialize, Deserialize)] // FIXME: Hash #[derive(Debug, Clone, Copy)] // FIXME: Hash
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct PerspectiveBase<N: Scalar, S: Storage<N, U4, U4>> { pub struct PerspectiveBase<N: Scalar, S: Storage<N, U4, U4>> {
matrix: SquareMatrix<N, U4, S> matrix: SquareMatrix<N, U4, S>
} }

View File

@ -23,7 +23,8 @@ pub type OwnedPoint<N, D, A> = PointBase<N, D, <A as Allocator<N, D, U1>>::Buffe
/// A point in a n-dimensional euclidean space. /// A point in a n-dimensional euclidean space.
#[repr(C)] #[repr(C)]
#[derive(Hash, Debug, Serialize, Deserialize)] #[derive(Hash, Debug)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct PointBase<N: Scalar, D: DimName, S: Storage<N, D, U1>> { pub struct PointBase<N: Scalar, D: DimName, S: Storage<N, D, U1>> {
/// The coordinates of this point, i.e., the shift from the origin. /// The coordinates of this point, i.e., the shift from the origin.
pub coords: ColumnVector<N, D, S> pub coords: ColumnVector<N, D, S>

View File

@ -21,7 +21,8 @@ pub type OwnedUnitQuaternionBase<N, A> = UnitQuaternionBase<N, <A as Allocator<N
/// A quaternion. See the type alias `UnitQuaternionBase = Unit<QuaternionBase>` for a quaternion /// A quaternion. See the type alias `UnitQuaternionBase = Unit<QuaternionBase>` for a quaternion
/// that may be used as a rotation. /// that may be used as a rotation.
#[repr(C)] #[repr(C)]
#[derive(Hash, Debug, Copy, Clone, Serialize, Deserialize)] #[derive(Hash, Debug, Copy, Clone)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct QuaternionBase<N: Real, S: Storage<N, U4, U1>> { pub struct QuaternionBase<N: Real, S: Storage<N, U4, U1>> {
/// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order. /// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order.
pub coords: ColumnVector<N, U4, S> pub coords: ColumnVector<N, U4, S>
@ -275,6 +276,121 @@ impl<N, S> fmt::Display for QuaternionBase<N, S>
} }
/// A unit quaternions. May be used to represent a rotation. /// A unit quaternions. May be used to represent a rotation.
///
///
/// <center>
/// <big><b>
/// Due to a [bug](https://github.com/rust-lang/rust/issues/32077) in rustdoc, the documentation
/// below has been written manually lists only method signatures.<br>
/// Trait implementations are not listed either.
/// </b></big>
/// </center>
///
/// Please refer directly to the documentation written above each function definition on the source
/// code for more details.
///
/// <h2 id="methods">Methods</h2>
///
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">angle</a>(&self) -> N</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">angle_to</a>(&self, other: &UnitQuaternionBase) -> N</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">axis</a>(&self) -> Option&lt;Unit&lt;OwnedColumnVector&gt;&gt;</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">clone_owned</a>(&self) -> OwnedUnitQuaternionBase</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">conjugate_mut</a>(&mut self)</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">conjugate</a>(&self) -> OwnedUnitQuaternionBase</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">exp</a>(&self) -> OwnedQuaternionBase</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">from_axis_angle</a>(axis: &Unit&lt;ColumnVector&gt;, angle: N) -> Self</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">from_euler_angles</a>(roll: N, pitch: N, yaw: N) -> Self</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">from_quaternion</a>(q: QuaternionBase) -> Self</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">from_rotation_matrix</a>(rotmat: &RotationBase) -> Self</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">from_scaled_axis</a>(axisangle: ColumnVector) -> Self</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">identity</a>() -> Self</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">into_owned</a>(self) -> OwnedUnitQuaternionBase</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">inverse_mut</a>(&mut self)</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">inverse</a>(&self) -> OwnedUnitQuaternionBase</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">lerp</a>(&self, other: &UnitQuaternionBase, t: N) -> OwnedQuaternionBase</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">ln</a>(&self) -> OwnedQuaternionBase</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">look_at_lh</a>(dir: &ColumnVector, up: &ColumnVector) -> Self</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">look_at_rh</a>(dir: &ColumnVector, up: &ColumnVector) -> Self</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">new</a>(axisangle: ColumnVector) -> Self</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">new_observer_frame</a>(dir: &ColumnVector, up: &ColumnVector) -> Self</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">nlerp</a>(&self, other: &UnitQuaternionBase, t: N) -> OwnedUnitQuaternionBase</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">powf</a>(&self, n: N) -> OwnedUnitQuaternionBase</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">quaternion</a>(&self) -> &QuaternionBase</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">rotation_between</a>(a: &ColumnVector, b: &ColumnVector) -> Option&lt;Self&gt;</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">rotation_to</a>(&self, other: &UnitQuaternionBase) -> OwnedUnitQuaternionBase</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">scaled_axis</a>(&self) -> OwnedColumnVector</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">scaled_rotation_between</a>(a: &ColumnVector, b: &ColumnVector, s: N) -> Option&lt;Self&gt;</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">slerp</a>(&self, other: &UnitQuaternionBase, t: N) -> OwnedUnitQuaternionBase</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">to_homogeneous</a>(&self) -> OwnedSquareMatrix</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">to_rotation_matrix</a>(&self) -> OwnedRotation</code>
/// </h4>
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">try_slerp</a>(&self, other: &UnitQuaternionBase, t: N, epsilon: N) -> Option&lt;OwnedUnitQuaternionBase&gt;</code>
/// </h4>
pub type UnitQuaternionBase<N, S> = Unit<QuaternionBase<N, S>>; pub type UnitQuaternionBase<N, S> = Unit<QuaternionBase<N, S>>;

View File

@ -15,7 +15,8 @@ pub type OwnedRotation<N, D, A> = RotationBase<N, D, <A as Allocator<N, D, D>>::
/// A rotation matrix. /// A rotation matrix.
#[repr(C)] #[repr(C)]
#[derive(Hash, Debug, Clone, Copy, Serialize, Deserialize)] #[derive(Hash, Debug, Clone, Copy)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct RotationBase<N: Scalar, D: DimName, S> { pub struct RotationBase<N: Scalar, D: DimName, S> {
matrix: SquareMatrix<N, D, S> matrix: SquareMatrix<N, D, S>
} }

View File

@ -17,7 +17,8 @@ pub type OwnedSimilarityBase<N, D, A, R> =
/// A similarity, i.e., an uniform scaling, followed by a rotation, followed by a translation. /// A similarity, i.e., an uniform scaling, followed by a rotation, followed by a translation.
#[repr(C)] #[repr(C)]
#[derive(Hash, Debug, Clone, Copy, Serialize, Deserialize)] #[derive(Hash, Debug, Clone, Copy)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct SimilarityBase<N: Scalar, D: DimName, S, R> { pub struct SimilarityBase<N: Scalar, D: DimName, S, R> {
/// The part of this similarity that does not include the scaling factor. /// The part of this similarity that does not include the scaling factor.
pub isometry: IsometryBase<N, D, S, R>, pub isometry: IsometryBase<N, D, S, R>,

View File

@ -52,15 +52,18 @@ where T1: TCategory,
} }
/// Tag representing the most general (not necessarily inversible) `Transform` type. /// Tag representing the most general (not necessarily inversible) `Transform` type.
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub enum TGeneral { } pub enum TGeneral { }
/// Tag representing the most general inversible `Transform` type. /// Tag representing the most general inversible `Transform` type.
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub enum TProjective { } pub enum TProjective { }
/// Tag representing an affine `Transform`. Its bottom-row is equal to `(0, 0 ... 0, 1)`. /// Tag representing an affine `Transform`. Its bottom-row is equal to `(0, 0 ... 0, 1)`.
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub enum TAffine { } pub enum TAffine { }
impl TCategory for TGeneral { impl TCategory for TGeneral {
@ -155,11 +158,12 @@ pub type OwnedTransform<N, D, A, C>
/// It is stored as a matrix with dimensions `(D + 1, D + 1)`, e.g., it stores a 4x4 matrix for a /// It is stored as a matrix with dimensions `(D + 1, D + 1)`, e.g., it stores a 4x4 matrix for a
/// 3D transformation. /// 3D transformation.
#[repr(C)] #[repr(C)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize)] // FIXME: Hash #[derive(Debug, Clone, Copy)] // FIXME: Hash
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct TransformBase<N: Scalar, D: DimNameAdd<U1>, S, C: TCategory> { pub struct TransformBase<N: Scalar, D: DimNameAdd<U1>, S, C: TCategory> {
matrix: SquareMatrix<N, DimNameSum<D, U1>, S>, matrix: SquareMatrix<N, DimNameSum<D, U1>, S>,
#[serde(skip_serializing, skip_deserializing)] #[cfg_attr(feature = "serde-serialize", serde(skip_serializing, skip_deserializing))]
_phantom: PhantomData<C> _phantom: PhantomData<C>
} }

View File

@ -14,7 +14,8 @@ pub type OwnedTranslation<N, D, S> = TranslationBase<N, D, Owned<N, D, U1, <S as
/// A translation. /// A translation.
#[repr(C)] #[repr(C)]
#[derive(Hash, Debug, Clone, Copy, Serialize, Deserialize)] #[derive(Hash, Debug, Clone, Copy)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct TranslationBase<N: Scalar, D: DimName, S/*: Storage<N, D, U1>*/> { pub struct TranslationBase<N: Scalar, D: DimName, S/*: Storage<N, D, U1>*/> {
/// The translation coordinates, i.e., how much is added to a point's coordinates when it is /// The translation coordinates, i.e., how much is added to a point's coordinates when it is
/// translated. /// translated.

View File

@ -8,6 +8,100 @@ use core::dimension::U2;
use geometry::Rotation2; use geometry::Rotation2;
/// A complex number with a norm equal to 1. /// A complex number with a norm equal to 1.
///
/// <center>
/// <big><b>
/// Due to a [bug](https://github.com/rust-lang/rust/issues/32077) in rustdoc, the documentation
/// below has been written manually lists only method signatures.<br>
/// Trait implementations are not listed either.
/// </b></big>
/// </center>
///
/// Please refer directly to the documentation written above each function definition on the source
/// code for more details.
///
///
/// <h2 id="methods">Methods</h2>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">angle</a>(&self) -> N</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">angle_to</a>(&self, other: &Self) -> N</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">complex</a>(&self) -> &Complex</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">conjugate</a>(&self) -> Self</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">conjugate_mut</a>(&mut self)</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">from_angle</a>(angle: N) -> Self</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">from_complex</a>(q: Complex) -> Self</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">from_rotation_matrix</a>(rotmat: &RotationBase) -> Self</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">from_scaled_axis</a>(axisangle: ColumnVector) -> Self</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">identity</a>() -> Self</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">inverse</a>(&self) -> Self</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">inverse_mut</a>(&mut self)</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">new</a>(angle: N) -> Self</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">powf</a>(&self, n: N) -> Self</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">rotation_between</a>(a: &ColumnVector<N, U2, SB>, b: &ColumnVector) -> Self</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">rotation_to</a>(&self, other: &Self) -> Self</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">scaled_axis</a>(&self) -> Vector1</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">scaled_rotation_between</a>(a: &ColumnVector<N, U2, SB>, b: &ColumnVector, s: N) -> Self</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">to_homogeneous</a>(&self) -> Matrix3</code>
/// </h4>
///
/// <h4 class="method"><span class="invisible">
/// <code>fn <a class="fnname">to_rotation_matrix</a>(&self) -> Rotation2</code>
/// </h4>
pub type UnitComplex<N> = Unit<Complex<N>>; pub type UnitComplex<N> = Unit<Complex<N>>;
impl<N: Real> UnitComplex<N> { impl<N: Real> UnitComplex<N> {

View File

@ -67,7 +67,7 @@ an optimized set of tools for computer graphics and physics. Those features incl
`Transform2`, `Transform3`. `Transform2`, `Transform3`.
* 3D projections for computer graphics: `Perspective3`, `Orthographic3`. * 3D projections for computer graphics: `Perspective3`, `Orthographic3`.
* Linear algebra and data analysis operators: QR decomposition, eigen-decomposition. * Linear algebra and data analysis operators: QR decomposition, eigen-decomposition.
* Implements all meaningful traits from the [alga](https://crates.io/crates/alga) crate for * Implements traits from the [alga](https://crates.io/crates/alga) crate for
generic programming. generic programming.
*/ */
@ -89,7 +89,9 @@ an optimized set of tools for computer graphics and physics. Those features incl
#[cfg(feature = "arbitrary")] #[cfg(feature = "arbitrary")]
extern crate quickcheck; extern crate quickcheck;
#[cfg(feature = "serde")]
extern crate serde; extern crate serde;
#[cfg(feature = "serde")]
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;
extern crate num_traits as num; extern crate num_traits as num;