Add sections to the Unit wrapper documentation

This commit is contained in:
Crozet Sébastien 2020-11-21 12:19:04 +01:00
parent c1372c3041
commit 651d318c26
2 changed files with 11 additions and 1 deletions

View File

@ -56,6 +56,7 @@ impl<N: Scalar + Zero + One + ClosedAdd + ClosedSub + ClosedMul, D: Dim, S: Stor
} }
} }
/// # Interpolation between two unit vectors
impl<N: RealField, D: Dim, S: Storage<N, D>> Unit<Vector<N, D, S>> { impl<N: RealField, D: Dim, S: Storage<N, D>> Unit<Vector<N, D, S>> {
/// Computes the spherical linear interpolation between two unit vectors. /// Computes the spherical linear interpolation between two unit vectors.
/// ///

View File

@ -15,7 +15,14 @@ use crate::{Dim, MatrixMN, RealField, Scalar, SimdComplexField, SimdRealField};
/// A wrapper that ensures the underlying algebraic entity has a unit norm. /// A wrapper that ensures the underlying algebraic entity has a unit norm.
/// ///
/// Use `.as_ref()` or `.into_inner()` to obtain the underlying value by-reference or by-move. /// **It is likely that the only piece of documentation that you need in this page are:**
/// - **[The construction with normalization](#construction-with-normalization)**
/// - **[Data extraction and construction without normalization](#data-extraction-and-construction-without-normalization)**
/// - **[Interpolation between two unit vectors](#interpolation-between-two-unit-vectors)**
///
/// All the other impl blocks you will see in this page are about [`UnitComplex`](crate::UnitComplex)
/// and [`UnitQuaternion`](crate::UnitQuaternion); both built on top of `Unit`. If you are interested
/// in their documentation, read their dedicated pages directly.
#[repr(transparent)] #[repr(transparent)]
#[derive(Eq, PartialEq, Clone, Hash, Debug, Copy)] #[derive(Eq, PartialEq, Clone, Hash, Debug, Copy)]
pub struct Unit<T> { pub struct Unit<T> {
@ -71,6 +78,7 @@ pub trait Normed {
fn unscale_mut(&mut self, n: Self::Norm); fn unscale_mut(&mut self, n: Self::Norm);
} }
/// # Construction with normalization
impl<T: Normed> Unit<T> { impl<T: Normed> Unit<T> {
/// Normalize the given vector and return it wrapped on a `Unit` structure. /// Normalize the given vector and return it wrapped on a `Unit` structure.
#[inline] #[inline]
@ -140,6 +148,7 @@ impl<T: Normed> Unit<T> {
} }
} }
/// # Data extraction and construction without normalization
impl<T> Unit<T> { impl<T> Unit<T> {
/// Wraps the given value, assuming it is already normalized. /// Wraps the given value, assuming it is already normalized.
#[inline] #[inline]