Merge branch 'master-public' into dev

# Conflicts:
#	Cargo.toml
#	src/base/matrix.rs
#	src/geometry/quaternion.rs
This commit is contained in:
sebcrozet 2019-03-31 16:33:25 +02:00
commit ae4afa3d2c
3 changed files with 16 additions and 8 deletions

View File

@ -294,7 +294,8 @@ impl<N: Scalar + Ring, D: DimName, S: StorageMut<N, D, D>> SquareMatrix<N, D, S>
{
for i in 0..D::dim() {
for j in 0..D::dim() - 1 {
self[(j, i)] += shift[j] * self[(D::dim() - 1, i)];
let add = shift[j] * self[(D::dim() - 1, i)];
self[(j, i)] += add;
}
}
}

View File

@ -1594,6 +1594,19 @@ impl<N: Scalar + Zero + One + ClosedAdd + ClosedSub + ClosedMul, D: Dim, S: Stor
impl<N: ComplexField, D: Dim, S: Storage<N, D>> Unit<Vector<N, D, S>> {
/// Computes the spherical linear interpolation between two unit vectors.
///
/// # Examples:
///
/// ```
/// # use nalgebra::geometry::UnitQuaternion;
///
/// let q1 = UnitQuaternion::from_euler_angles(std::f32::consts::FRAC_PI_4, 0.0, 0.0);
/// let q2 = UnitQuaternion::from_euler_angles(-std::f32::consts::PI, 0.0, 0.0);
///
/// let q = q1.slerp(&q2, 1.0 / 3.0);
///
/// assert_eq!(q.euler_angles(), (std::f32::consts::FRAC_PI_2, 0.0, 0.0));
/// ```
pub fn slerp<S2: Storage<N, D>>(
&self,
rhs: &Unit<Vector<N, D, S2>>,

View File

@ -945,13 +945,7 @@ impl<N: RealField> UnitQuaternion<N> {
#[inline]
pub fn angle(&self) -> N {
let w = self.quaternion().scalar().abs();
// Handle inaccuracies that make break `.acos`.
if w >= N::one() {
N::zero()
} else {
w.acos() * crate::convert(2.0f64)
}
self.quaternion().imag().norm().atan2(w) * crate::convert(2.0f64)
}
/// The underlying quaternion.