forked from M-Labs/nalgebra
Always use Cast<f64>
instead of Cast<f32>
.
This commit is contained in:
parent
6b4b25acd4
commit
93b184815f
@ -383,7 +383,7 @@ pub fn sqdist<N: Float, P: FloatPnt<N, V>, V: Norm<N>>(a: &P, b: &P) -> N {
|
||||
/// Computes a projection matrix given the frustrum near plane width, height, the field of
|
||||
/// view, and the distance to the clipping planes (`znear` and `zfar`).
|
||||
#[deprecated = "Use `Persp3::new(width / height, fov, znear, zfar).as_mat()` instead"]
|
||||
pub fn perspective3d<N: FloatMath + Cast<f32> + Zero + One>(width: N, height: N, fov: N, znear: N, zfar: N) -> Mat4<N> {
|
||||
pub fn perspective3d<N: FloatMath + Cast<f64> + Zero + One>(width: N, height: N, fov: N, znear: N, zfar: N) -> Mat4<N> {
|
||||
let aspect = width / height;
|
||||
|
||||
let _1: N = one();
|
||||
|
@ -500,10 +500,10 @@ impl<N: Clone> Transpose for DMat<N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: Num + Cast<f32> + Clone> Mean<DVec<N>> for DMat<N> {
|
||||
impl<N: Num + Cast<f64> + Clone> Mean<DVec<N>> for DMat<N> {
|
||||
fn mean(m: &DMat<N>) -> DVec<N> {
|
||||
let mut res: DVec<N> = DVec::new_zeros(m.ncols);
|
||||
let normalizer: N = Cast::from(1.0f32 / Cast::from(m.nrows));
|
||||
let normalizer: N = Cast::from(1.0f64 / Cast::from(m.nrows));
|
||||
|
||||
for i in range(0u, m.nrows) {
|
||||
for j in range(0u, m.ncols) {
|
||||
@ -518,7 +518,7 @@ impl<N: Num + Cast<f32> + Clone> Mean<DVec<N>> for DMat<N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: Clone + Num + Cast<f32> + DMatDivRhs<N, DMat<N>>> Cov<DMat<N>> for DMat<N> {
|
||||
impl<N: Clone + Num + Cast<f64> + DMatDivRhs<N, DMat<N>>> Cov<DMat<N>> for DMat<N> {
|
||||
// FIXME: this could be heavily optimized, removing all temporaries by merging loops.
|
||||
fn cov(m: &DMat<N>) -> DMat<N> {
|
||||
assert!(m.nrows > 1);
|
||||
@ -536,7 +536,7 @@ impl<N: Clone + Num + Cast<f32> + DMatDivRhs<N, DMat<N>>> Cov<DMat<N>> for DMat<
|
||||
}
|
||||
|
||||
// FIXME: return a triangular matrix?
|
||||
let fnormalizer: f32 = Cast::from(m.nrows() - 1);
|
||||
let fnormalizer: f64 = Cast::from(m.nrows() - 1);
|
||||
let normalizer: N = Cast::from(fnormalizer);
|
||||
// FIXME: this will do 2 allocations for temporaries!
|
||||
(Transpose::transpose_cpy(¢ered) * centered) / normalizer
|
||||
|
@ -26,7 +26,7 @@ macro_rules! iso_impl(
|
||||
|
||||
macro_rules! rotation_matrix_impl(
|
||||
($t: ident, $trot: ident, $tlv: ident, $tav: ident) => (
|
||||
impl<N: Cast<f32> + FloatMath + Num + Clone>
|
||||
impl<N: Cast<f64> + FloatMath + Num + Clone>
|
||||
RotationMatrix<N, $tlv<N>, $tav<N>, $trot<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn to_rot_mat(&self) -> $trot<N> {
|
||||
@ -153,7 +153,7 @@ macro_rules! translate_impl(
|
||||
|
||||
macro_rules! rotation_impl(
|
||||
($t: ident, $trot: ident, $tav: ident) => (
|
||||
impl<N: Cast<f32> + FloatMath + Clone> Rotation<$tav<N>> for $t<N> {
|
||||
impl<N: Cast<f64> + FloatMath + Clone> Rotation<$tav<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn rotation(&self) -> $tav<N> {
|
||||
self.rotation.rotation()
|
||||
|
@ -205,7 +205,7 @@ impl<N: Clone + Float> Rot3<N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: Clone + FloatMath + Cast<f32>>
|
||||
impl<N: Clone + FloatMath + Cast<f64>>
|
||||
Rotation<Vec3<N>> for Rot3<N> {
|
||||
#[inline]
|
||||
fn rotation(&self) -> Vec3<N> {
|
||||
|
@ -122,7 +122,7 @@ macro_rules! dim_impl(
|
||||
|
||||
macro_rules! rotation_matrix_impl(
|
||||
($t: ident, $tlv: ident, $tav: ident) => (
|
||||
impl<N: Cast<f32> + FloatMath> RotationMatrix<N, $tlv<N>, $tav<N>, $t<N>> for $t<N> {
|
||||
impl<N: Cast<f64> + FloatMath> RotationMatrix<N, $tlv<N>, $tav<N>, $t<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn to_rot_mat(&self) -> $t<N> {
|
||||
self.clone()
|
||||
|
@ -154,7 +154,7 @@ impl<N: Float> Basis for Vec3<N> {
|
||||
}
|
||||
|
||||
// FIXME: this bad: this fixes definitly the number of samples…
|
||||
static SAMPLES_2_F32: [Vec2<f32>, ..21] = [
|
||||
static SAMPLES_2_F64: [Vec2<f64>, ..21] = [
|
||||
Vec2 { x: 1.0, y: 0.0 },
|
||||
Vec2 { x: 0.95557281, y: 0.29475517 },
|
||||
Vec2 { x: 0.82623877, y: 0.56332006 },
|
||||
@ -179,7 +179,7 @@ static SAMPLES_2_F32: [Vec2<f32>, ..21] = [
|
||||
];
|
||||
|
||||
// Those vectors come from bullet 3d
|
||||
static SAMPLES_3_F32: [Vec3<f32>, ..42] = [
|
||||
static SAMPLES_3_F64: [Vec3<f64>, ..42] = [
|
||||
Vec3 { x: 0.000000 , y: -0.000000, z: -1.000000 },
|
||||
Vec3 { x: 0.723608 , y: -0.525725, z: -0.447219 },
|
||||
Vec3 { x: -0.276388, y: -0.850649, z: -0.447219 },
|
||||
@ -231,25 +231,25 @@ impl<N: One + Clone> UniformSphereSample for Vec1<N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: Cast<f32> + Clone> UniformSphereSample for Vec2<N> {
|
||||
impl<N: Cast<f64> + Clone> UniformSphereSample for Vec2<N> {
|
||||
#[inline(always)]
|
||||
fn sample(f: |Vec2<N>| -> ()) {
|
||||
for sample in SAMPLES_2_F32.iter() {
|
||||
for sample in SAMPLES_2_F64.iter() {
|
||||
f(Cast::from(*sample))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: Cast<f32> + Clone> UniformSphereSample for Vec3<N> {
|
||||
impl<N: Cast<f64> + Clone> UniformSphereSample for Vec3<N> {
|
||||
#[inline(always)]
|
||||
fn sample(f: |Vec3<N>| -> ()) {
|
||||
for sample in SAMPLES_3_F32.iter() {
|
||||
for sample in SAMPLES_3_F64.iter() {
|
||||
f(Cast::from(*sample))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: Cast<f32> + Clone> UniformSphereSample for Vec4<N> {
|
||||
impl<N: Cast<f64> + Clone> UniformSphereSample for Vec4<N> {
|
||||
#[inline(always)]
|
||||
fn sample(_: |Vec4<N>| -> ()) {
|
||||
panic!("UniformSphereSample::<Vec4<N>>::sample : Not yet implemented.")
|
||||
|
Loading…
Reference in New Issue
Block a user