Merge pull request #955 from qu1x/reflection

Add bias getter and alias for reflection.
This commit is contained in:
Sébastien Crozet 2021-08-01 10:29:11 +02:00 committed by GitHub
commit 441bfcb3ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 2 deletions

View File

@ -73,6 +73,7 @@ mod transform_ops;
mod transform_simba; mod transform_simba;
mod reflection; mod reflection;
mod reflection_alias;
mod orthographic; mod orthographic;
mod perspective; mod perspective;
@ -104,6 +105,7 @@ pub use self::transform::*;
pub use self::transform_alias::*; pub use self::transform_alias::*;
pub use self::reflection::*; pub use self::reflection::*;
pub use self::reflection_alias::*;
pub use self::orthographic::Orthographic3; pub use self::orthographic::Orthographic3;
pub use self::perspective::Perspective3; pub use self::perspective::Perspective3;

View File

@ -22,7 +22,7 @@ impl<T: ComplexField, S: Storage<T, Const<D>>, const D: usize> Reflection<T, Con
} }
impl<T: ComplexField, D: Dim, S: Storage<T, D>> Reflection<T, D, S> { impl<T: ComplexField, D: Dim, S: Storage<T, D>> Reflection<T, D, S> {
/// Creates a new reflection wrt the plane orthogonal to the given axis and bias. /// Creates a new reflection wrt. the plane orthogonal to the given axis and bias.
/// ///
/// The bias is the position of the plane on the axis. In particular, a bias equal to zero /// The bias is the position of the plane on the axis. In particular, a bias equal to zero
/// represents a plane that passes through the origin. /// represents a plane that passes through the origin.
@ -33,12 +33,21 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D>> Reflection<T, D, S> {
} }
} }
/// The reflexion axis. /// The reflection axis.
#[must_use] #[must_use]
pub fn axis(&self) -> &Vector<T, D, S> { pub fn axis(&self) -> &Vector<T, D, S> {
&self.axis &self.axis
} }
/// The reflection bias.
///
/// The bias is the position of the plane on the axis. In particular, a bias equal to zero
/// represents a plane that passes through the origin.
#[must_use]
pub fn bias(&self) -> T {
self.bias
}
// TODO: naming convention: reflect_to, reflect_assign ? // TODO: naming convention: reflect_to, reflect_assign ?
/// Applies the reflection to the columns of `rhs`. /// Applies the reflection to the columns of `rhs`.
pub fn reflect<R2: Dim, C2: Dim, S2>(&self, rhs: &mut Matrix<T, R2, C2, S2>) pub fn reflect<R2: Dim, C2: Dim, S2>(&self, rhs: &mut Matrix<T, R2, C2, S2>)

View File

@ -0,0 +1,21 @@
use crate::base::ArrayStorage;
use crate::geometry::Reflection;
use crate::Const;
/// A 1-dimensional reflection.
pub type Reflection1<T> = Reflection<T, Const<1>, ArrayStorage<T, 1, 1>>;
/// A 2-dimensional reflection.
pub type Reflection2<T> = Reflection<T, Const<2>, ArrayStorage<T, 2, 1>>;
/// A 3-dimensional reflection.
pub type Reflection3<T> = Reflection<T, Const<3>, ArrayStorage<T, 3, 1>>;
/// A 4-dimensional reflection.
pub type Reflection4<T> = Reflection<T, Const<4>, ArrayStorage<T, 4, 1>>;
/// A 5-dimensional reflection.
pub type Reflection5<T> = Reflection<T, Const<5>, ArrayStorage<T, 5, 1>>;
/// A 6-dimensional reflection.
pub type Reflection6<T> = Reflection<T, Const<6>, ArrayStorage<T, 6, 1>>;