commit
737e67c555
|
@ -79,18 +79,18 @@ impl<N: RealField> Matrix3<N> {
|
|||
/// Can be used to implement "zoom_to" functionality.
|
||||
#[inline]
|
||||
pub fn new_nonuniform_scaling_wrt_point(scaling: &Vector2<N>, pt: &Point2<N>) -> Self {
|
||||
let _0 = N::zero();
|
||||
let _1 = N::one();
|
||||
let zero = N::zero();
|
||||
let one = N::one();
|
||||
Matrix3::new(
|
||||
scaling.x,
|
||||
_0,
|
||||
zero,
|
||||
pt.x - pt.x * scaling.x,
|
||||
_0,
|
||||
zero,
|
||||
scaling.y,
|
||||
pt.y - pt.y * scaling.y,
|
||||
_0,
|
||||
_0,
|
||||
_1,
|
||||
zero,
|
||||
zero,
|
||||
one,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -119,25 +119,25 @@ impl<N: RealField> Matrix4<N> {
|
|||
/// Can be used to implement "zoom_to" functionality.
|
||||
#[inline]
|
||||
pub fn new_nonuniform_scaling_wrt_point(scaling: &Vector3<N>, pt: &Point3<N>) -> Self {
|
||||
let _0 = N::zero();
|
||||
let _1 = N::one();
|
||||
let zero = N::zero();
|
||||
let one = N::one();
|
||||
Matrix4::new(
|
||||
scaling.x,
|
||||
_0,
|
||||
_0,
|
||||
zero,
|
||||
zero,
|
||||
pt.x - pt.x * scaling.x,
|
||||
_0,
|
||||
zero,
|
||||
scaling.y,
|
||||
_0,
|
||||
zero,
|
||||
pt.y - pt.y * scaling.y,
|
||||
_0,
|
||||
_0,
|
||||
zero,
|
||||
zero,
|
||||
scaling.z,
|
||||
pt.z - pt.z * scaling.z,
|
||||
_0,
|
||||
_0,
|
||||
_0,
|
||||
_1,
|
||||
zero,
|
||||
zero,
|
||||
zero,
|
||||
one,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ where
|
|||
SB: Storage<N, U1, C>,
|
||||
{
|
||||
assert!(rows.len() > 0, "At least one row must be given.");
|
||||
let nrows = R::try_to_usize().unwrap_or(rows.len());
|
||||
let nrows = R::try_to_usize().unwrap_or_else(|| rows.len());
|
||||
let ncols = rows[0].len();
|
||||
assert!(
|
||||
rows.len() == nrows,
|
||||
|
@ -803,8 +803,8 @@ where
|
|||
{
|
||||
#[inline]
|
||||
fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> MatrixMN<N, R, C> {
|
||||
let nrows = R::try_to_usize().unwrap_or(rng.gen_range(0, 10));
|
||||
let ncols = C::try_to_usize().unwrap_or(rng.gen_range(0, 10));
|
||||
let nrows = R::try_to_usize().unwrap_or_else(|| rng.gen_range(0, 10));
|
||||
let ncols = C::try_to_usize().unwrap_or_else(|| rng.gen_range(0, 10));
|
||||
|
||||
MatrixMN::from_fn_generic(R::from_usize(nrows), C::from_usize(ncols), |_, _| rng.gen())
|
||||
}
|
||||
|
|
|
@ -48,11 +48,11 @@ macro_rules! iterator {
|
|||
};
|
||||
|
||||
$Name {
|
||||
ptr: ptr,
|
||||
ptr,
|
||||
inner_ptr: ptr,
|
||||
inner_end,
|
||||
size: shape.0.value() * shape.1.value(),
|
||||
strides: strides,
|
||||
strides,
|
||||
_phantoms: PhantomData,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ macro_rules! slice_storage_impl(
|
|||
CStride: Dim {
|
||||
|
||||
$T {
|
||||
ptr: ptr,
|
||||
shape: shape,
|
||||
strides: strides,
|
||||
ptr,
|
||||
shape,
|
||||
strides,
|
||||
_phantoms: PhantomData
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,9 +134,9 @@ impl<T: Normed> Unit<T> {
|
|||
#[inline]
|
||||
pub fn renormalize_fast(&mut self) {
|
||||
let sq_norm = self.value.norm_squared();
|
||||
let _3: T::Norm = crate::convert(3.0);
|
||||
let _0_5: T::Norm = crate::convert(0.5);
|
||||
self.value.scale_mut(_0_5 * (_3 - sq_norm));
|
||||
let three: T::Norm = crate::convert(3.0);
|
||||
let half: T::Norm = crate::convert(0.5);
|
||||
self.value.scale_mut(half * (three - sq_norm));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -285,13 +285,13 @@ where
|
|||
// Robust matrix to quaternion transformation.
|
||||
// See https://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion
|
||||
let tr = rotmat[(0, 0)] + rotmat[(1, 1)] + rotmat[(2, 2)];
|
||||
let _0_25: N = crate::convert(0.25);
|
||||
let quarter: N = crate::convert(0.25);
|
||||
|
||||
let res = tr.simd_gt(N::zero()).if_else3(
|
||||
|| {
|
||||
let denom = (tr + N::one()).simd_sqrt() * crate::convert(2.0);
|
||||
Quaternion::new(
|
||||
_0_25 * denom,
|
||||
quarter * denom,
|
||||
(rotmat[(2, 1)] - rotmat[(1, 2)]) / denom,
|
||||
(rotmat[(0, 2)] - rotmat[(2, 0)]) / denom,
|
||||
(rotmat[(1, 0)] - rotmat[(0, 1)]) / denom,
|
||||
|
@ -305,7 +305,7 @@ where
|
|||
* crate::convert(2.0);
|
||||
Quaternion::new(
|
||||
(rotmat[(2, 1)] - rotmat[(1, 2)]) / denom,
|
||||
_0_25 * denom,
|
||||
quarter * denom,
|
||||
(rotmat[(0, 1)] + rotmat[(1, 0)]) / denom,
|
||||
(rotmat[(0, 2)] + rotmat[(2, 0)]) / denom,
|
||||
)
|
||||
|
@ -320,7 +320,7 @@ where
|
|||
Quaternion::new(
|
||||
(rotmat[(0, 2)] - rotmat[(2, 0)]) / denom,
|
||||
(rotmat[(0, 1)] + rotmat[(1, 0)]) / denom,
|
||||
_0_25 * denom,
|
||||
quarter * denom,
|
||||
(rotmat[(1, 2)] + rotmat[(2, 1)]) / denom,
|
||||
)
|
||||
},
|
||||
|
@ -333,7 +333,7 @@ where
|
|||
(rotmat[(1, 0)] - rotmat[(0, 1)]) / denom,
|
||||
(rotmat[(0, 2)] + rotmat[(2, 0)]) / denom,
|
||||
(rotmat[(1, 2)] + rotmat[(2, 1)]) / denom,
|
||||
_0_25 * denom,
|
||||
quarter * denom,
|
||||
)
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue