Make serde optional behind the "serde-serialize" feature.
This commit is contained in:
parent
896ad19dd0
commit
42b48563be
|
@ -3,5 +3,7 @@ language: rust
|
|||
script:
|
||||
- rustc --version
|
||||
- cargo --version
|
||||
- cargo build --verbose
|
||||
- cargo build --verbose --features arbitrary
|
||||
- cargo test --verbose --features arbitrary
|
||||
- cargo build --verbose --features serde-serialize
|
||||
- cargo test --verbose --features arbitrary serde-serialize
|
||||
|
|
|
@ -10,6 +10,8 @@ overview of all the added/modified features.
|
|||
|
||||
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.
|
||||
All other mathematical traits, except `Axpy` have been removed from
|
||||
**nalgebra**.
|
||||
* Methods are now preferred to free functions because they do not require any
|
||||
trait to be used any more.
|
||||
* 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
|
||||
2D rotations), affine/projective/general transformations with `Affine2/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.
|
||||
|
||||
### Added
|
||||
|
|
|
@ -17,6 +17,7 @@ path = "src/lib.rs"
|
|||
|
||||
[features]
|
||||
arbitrary = [ "quickcheck" ]
|
||||
serde-serialize = [ "serde", "serde_derive" ]
|
||||
|
||||
[dependencies]
|
||||
typenum = "1.4"
|
||||
|
@ -25,9 +26,9 @@ rand = "0.3"
|
|||
num-traits = "0.1"
|
||||
num-complex = "0.1"
|
||||
approx = "0.1"
|
||||
alga = "0.4"
|
||||
serde = "0.9"
|
||||
serde_derive = "0.9"
|
||||
alga = "0.5"
|
||||
serde = { version = "0.9", optional = true }
|
||||
serde_derive = { version = "0.9", optional = true }
|
||||
# clippy = "*"
|
||||
|
||||
[dependencies.quickcheck]
|
||||
|
|
6
Makefile
6
Makefile
|
@ -1,11 +1,11 @@
|
|||
all:
|
||||
CARGO_INCREMENTAL=1 cargo build --features "arbitrary"
|
||||
CARGO_INCREMENTAL=1 cargo build --features "arbitrary serde-serialize"
|
||||
|
||||
doc:
|
||||
CARGO_INCREMENTAL=1 cargo doc --no-deps
|
||||
CARGO_INCREMENTAL=1 cargo doc --no-deps --features "arbitrary serde-serialize"
|
||||
|
||||
bench:
|
||||
cargo bench
|
||||
|
||||
test:
|
||||
CARGO_INCREMENTAL=1 cargo test --features "arbitrary"
|
||||
CARGO_INCREMENTAL=1 cargo test --features "arbitrary serde-serialize"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</p>
|
||||
<p align = "center">
|
||||
<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>
|
||||
</p>
|
||||
|
||||
|
|
|
@ -23,7 +23,8 @@ macro_rules! coords_impl(
|
|||
/// 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.
|
||||
#[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 $comps: N),*
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ use std::ops::{Add, Sub, Mul, Div};
|
|||
use typenum::{self, Unsigned, UInt, B1, Bit, UTerm, Sum, Prod, Diff, Quot};
|
||||
|
||||
/// 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 {
|
||||
value: usize
|
||||
}
|
||||
|
@ -161,7 +162,8 @@ pub trait NamedDim: Sized + Any + Unsigned {
|
|||
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;
|
||||
|
||||
impl Dim for U1 {
|
||||
|
@ -197,7 +199,8 @@ impl NamedDim for typenum::U1{
|
|||
|
||||
macro_rules! named_dimension(
|
||||
($($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;
|
||||
|
||||
impl Dim for $D {
|
||||
|
|
|
@ -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
|
||||
/// some concrete types for `N` and a compatible data storage type `S`).
|
||||
#[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> {
|
||||
/// The data storage that contains all the matrix components and informations about its number
|
||||
/// of rows and column (if needed).
|
||||
pub data: S,
|
||||
|
||||
#[serde(skip_serializing, skip_deserializing)]
|
||||
#[cfg_attr(feature = "serde-serialize", serde(skip_serializing, skip_deserializing))]
|
||||
_phantoms: PhantomData<(N, R, C)>
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
use std::mem;
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::{Deref, DerefMut, Mul};
|
||||
use std::fmt::{self, Debug, Formatter};
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
use serde::{Serialize, Serializer, Deserialize, Deserializer};
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
use serde::ser::SerializeSeq;
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
use serde::de::{SeqVisitor, Visitor};
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
use std::mem;
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use typenum::Prod;
|
||||
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?
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
impl<N, R, C> Serialize for MatrixArray<N, R, C>
|
||||
where N: Scalar + Serialize,
|
||||
R: DimName,
|
||||
|
@ -220,6 +227,7 @@ where N: Scalar + Serialize,
|
|||
}
|
||||
|
||||
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
impl<N, R, C> Deserialize for MatrixArray<N, R, C>
|
||||
where N: Scalar + Deserialize,
|
||||
R: DimName,
|
||||
|
@ -237,11 +245,13 @@ where N: Scalar + Deserialize,
|
|||
}
|
||||
|
||||
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
/// A visitor that produces a matrix array.
|
||||
struct MatrixArrayVisitor<N, R, C> {
|
||||
marker: PhantomData<(N, R, C)>
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
impl<N, R, C> MatrixArrayVisitor<N, R, C>
|
||||
where N: Scalar,
|
||||
R: DimName,
|
||||
|
@ -257,6 +267,7 @@ where N: Scalar,
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde-serialize")]
|
||||
impl<N, R, C> Visitor for MatrixArrayVisitor<N, R, C>
|
||||
where N: Scalar + Deserialize,
|
||||
R: DimName,
|
||||
|
|
|
@ -12,7 +12,8 @@ use core::default_allocator::DefaultAllocator;
|
|||
*/
|
||||
/// A Vec-based matrix data storage. It may be dynamically-sized.
|
||||
#[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> {
|
||||
data: Vec<N>,
|
||||
nrows: R,
|
||||
|
|
|
@ -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 constraint;
|
||||
|
|
|
@ -10,7 +10,8 @@ use alga::linear::NormedSpace;
|
|||
///
|
||||
/// Use `.as_ref()` or `.unwrap()` to obtain the undelying value by-reference or by-move.
|
||||
#[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> {
|
||||
value: T
|
||||
}
|
||||
|
|
|
@ -18,7 +18,8 @@ pub type OwnedIsometryBase<N, D, A, R> =
|
|||
|
||||
/// A direct isometry, i.e., a rotation followed by a translation.
|
||||
#[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> {
|
||||
/// The pure rotational part of this isometry.
|
||||
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.
|
||||
#[serde(skip_serializing, skip_deserializing)]
|
||||
#[cfg_attr(feature = "serde-serialize", serde(skip_serializing, skip_deserializing))]
|
||||
_noconstruct: PhantomData<N>
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -13,7 +13,8 @@ use core::helper;
|
|||
use geometry::{PointBase, OwnedPoint};
|
||||
|
||||
/// 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>> {
|
||||
matrix: SquareMatrix<N, U4, S>
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ use core::helper;
|
|||
use geometry::{PointBase, OwnedPoint};
|
||||
|
||||
/// 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>> {
|
||||
matrix: SquareMatrix<N, U4, S>
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
#[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>> {
|
||||
/// The coordinates of this point, i.e., the shift from the origin.
|
||||
pub coords: ColumnVector<N, D, S>
|
||||
|
|
|
@ -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
|
||||
/// that may be used as a rotation.
|
||||
#[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>> {
|
||||
/// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order.
|
||||
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.
|
||||
///
|
||||
///
|
||||
/// <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<Unit<OwnedColumnVector>></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<ColumnVector>, 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<Self></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<Self></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<OwnedUnitQuaternionBase></code>
|
||||
/// </h4>
|
||||
pub type UnitQuaternionBase<N, S> = Unit<QuaternionBase<N, S>>;
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@ pub type OwnedRotation<N, D, A> = RotationBase<N, D, <A as Allocator<N, D, D>>::
|
|||
|
||||
/// A rotation matrix.
|
||||
#[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> {
|
||||
matrix: SquareMatrix<N, D, S>
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
#[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> {
|
||||
/// The part of this similarity that does not include the scaling factor.
|
||||
pub isometry: IsometryBase<N, D, S, R>,
|
||||
|
|
|
@ -52,15 +52,18 @@ where T1: TCategory,
|
|||
}
|
||||
|
||||
/// 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 { }
|
||||
|
||||
/// 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 { }
|
||||
|
||||
/// 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 { }
|
||||
|
||||
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
|
||||
/// 3D transformation.
|
||||
#[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> {
|
||||
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>
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ pub type OwnedTranslation<N, D, S> = TranslationBase<N, D, Owned<N, D, U1, <S as
|
|||
|
||||
/// A translation.
|
||||
#[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>*/> {
|
||||
/// The translation coordinates, i.e., how much is added to a point's coordinates when it is
|
||||
/// translated.
|
||||
|
|
|
@ -8,6 +8,100 @@ use core::dimension::U2;
|
|||
use geometry::Rotation2;
|
||||
|
||||
/// 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>>;
|
||||
|
||||
impl<N: Real> UnitComplex<N> {
|
||||
|
|
|
@ -67,7 +67,7 @@ an optimized set of tools for computer graphics and physics. Those features incl
|
|||
`Transform2`, `Transform3`.
|
||||
* 3D projections for computer graphics: `Perspective3`, `Orthographic3`.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
@ -89,7 +89,9 @@ an optimized set of tools for computer graphics and physics. Those features incl
|
|||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
extern crate quickcheck;
|
||||
#[cfg(feature = "serde")]
|
||||
extern crate serde;
|
||||
#[cfg(feature = "serde")]
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
extern crate num_traits as num;
|
||||
|
|
Loading…
Reference in New Issue