forked from M-Labs/nalgebra
Fix deprecation warnings.
This commit is contained in:
parent
b74aeb12e2
commit
f36ff97d6a
@ -4,7 +4,8 @@ macro_rules! bench_binop(
|
||||
($name: ident, $t1: ty, $t2: ty, $binop: ident) => {
|
||||
#[bench]
|
||||
fn $name(bh: &mut Bencher) {
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
use rand::SeedableRng;
|
||||
let mut rng = IsaacRng::seed_from_u64(0);
|
||||
let a = rng.gen::<$t1>();
|
||||
let b = rng.gen::<$t2>();
|
||||
|
||||
@ -19,7 +20,8 @@ macro_rules! bench_binop_ref(
|
||||
($name: ident, $t1: ty, $t2: ty, $binop: ident) => {
|
||||
#[bench]
|
||||
fn $name(bh: &mut Bencher) {
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
use rand::SeedableRng;
|
||||
let mut rng = IsaacRng::seed_from_u64(0);
|
||||
let a = rng.gen::<$t1>();
|
||||
let b = rng.gen::<$t2>();
|
||||
|
||||
@ -34,7 +36,8 @@ macro_rules! bench_binop_fn(
|
||||
($name: ident, $t1: ty, $t2: ty, $binop: path) => {
|
||||
#[bench]
|
||||
fn $name(bh: &mut Bencher) {
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
use rand::SeedableRng;
|
||||
let mut rng = IsaacRng::seed_from_u64(0);
|
||||
let a = rng.gen::<$t1>();
|
||||
let b = rng.gen::<$t2>();
|
||||
|
||||
@ -51,7 +54,8 @@ macro_rules! bench_unop_na(
|
||||
fn $name(bh: &mut Bencher) {
|
||||
const LEN: usize = 1 << 13;
|
||||
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
use rand::SeedableRng;
|
||||
let mut rng = IsaacRng::seed_from_u64(0);
|
||||
|
||||
let elems: Vec<$t> = (0usize .. LEN).map(|_| rng.gen::<$t>()).collect();
|
||||
let mut i = 0;
|
||||
@ -73,7 +77,8 @@ macro_rules! bench_unop(
|
||||
fn $name(bh: &mut Bencher) {
|
||||
const LEN: usize = 1 << 13;
|
||||
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
use rand::SeedableRng;
|
||||
let mut rng = IsaacRng::seed_from_u64(0);
|
||||
|
||||
let mut elems: Vec<$t> = (0usize .. LEN).map(|_| rng.gen::<$t>()).collect();
|
||||
let mut i = 0;
|
||||
@ -95,7 +100,8 @@ macro_rules! bench_construction(
|
||||
fn $name(bh: &mut Bencher) {
|
||||
const LEN: usize = 1 << 13;
|
||||
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
use rand::SeedableRng;
|
||||
let mut rng = IsaacRng::seed_from_u64(0);
|
||||
|
||||
$(let $args: Vec<$types> = (0usize .. LEN).map(|_| rng.gen::<$types>()).collect();)*
|
||||
let mut i = 0;
|
||||
|
@ -50,7 +50,8 @@ bench_binop_ref!(vec10000_dot_f32, VectorN<f32, U10000>, VectorN<f32, U10000>, d
|
||||
|
||||
#[bench]
|
||||
fn vec10000_axpy_f64(bh: &mut Bencher) {
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
use rand::SeedableRng;
|
||||
let mut rng = IsaacRng::seed_from_u64(0);
|
||||
let mut a = DVector::new_random(10000);
|
||||
let b = DVector::new_random(10000);
|
||||
let n = rng.gen::<f64>();
|
||||
@ -60,7 +61,8 @@ fn vec10000_axpy_f64(bh: &mut Bencher) {
|
||||
|
||||
#[bench]
|
||||
fn vec10000_axpy_beta_f64(bh: &mut Bencher) {
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
use rand::SeedableRng;
|
||||
let mut rng = IsaacRng::seed_from_u64(0);
|
||||
let mut a = DVector::new_random(10000);
|
||||
let b = DVector::new_random(10000);
|
||||
let n = rng.gen::<f64>();
|
||||
@ -71,7 +73,8 @@ fn vec10000_axpy_beta_f64(bh: &mut Bencher) {
|
||||
|
||||
#[bench]
|
||||
fn vec10000_axpy_f64_slice(bh: &mut Bencher) {
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
use rand::SeedableRng;
|
||||
let mut rng = IsaacRng::seed_from_u64(0);
|
||||
let mut a = DVector::new_random(10000);
|
||||
let b = DVector::new_random(10000);
|
||||
let n = rng.gen::<f64>();
|
||||
@ -86,7 +89,8 @@ fn vec10000_axpy_f64_slice(bh: &mut Bencher) {
|
||||
|
||||
#[bench]
|
||||
fn vec10000_axpy_f64_static(bh: &mut Bencher) {
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
use rand::SeedableRng;
|
||||
let mut rng = IsaacRng::seed_from_u64(0);
|
||||
let mut a = VectorN::<f64, U10000>::new_random();
|
||||
let b = VectorN::<f64, U10000>::new_random();
|
||||
let n = rng.gen::<f64>();
|
||||
@ -97,7 +101,8 @@ fn vec10000_axpy_f64_static(bh: &mut Bencher) {
|
||||
|
||||
#[bench]
|
||||
fn vec10000_axpy_f32(bh: &mut Bencher) {
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
use rand::SeedableRng;
|
||||
let mut rng = IsaacRng::seed_from_u64(0);
|
||||
let mut a = DVector::new_random(10000);
|
||||
let b = DVector::new_random(10000);
|
||||
let n = rng.gen::<f32>();
|
||||
@ -107,7 +112,8 @@ fn vec10000_axpy_f32(bh: &mut Bencher) {
|
||||
|
||||
#[bench]
|
||||
fn vec10000_axpy_beta_f32(bh: &mut Bencher) {
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
use rand::SeedableRng;
|
||||
let mut rng = IsaacRng::seed_from_u64(0);
|
||||
let mut a = DVector::new_random(10000);
|
||||
let b = DVector::new_random(10000);
|
||||
let n = rng.gen::<f32>();
|
||||
|
@ -14,6 +14,7 @@ mod geometry;
|
||||
mod linalg;
|
||||
|
||||
fn reproductible_dmatrix(nrows: usize, ncols: usize) -> DMatrix<f64> {
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
use rand::SeedableRng;
|
||||
let mut rng = IsaacRng::seed_from_u64(0);
|
||||
DMatrix::<f64>::from_fn(nrows, ncols, |_, _| rng.gen())
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ extern crate alga;
|
||||
extern crate approx;
|
||||
extern crate nalgebra as na;
|
||||
|
||||
use alga::linear::Transformation;
|
||||
use na::{Matrix4, Point3, Vector3};
|
||||
|
||||
fn main() {
|
||||
|
@ -1,7 +1,6 @@
|
||||
extern crate alga;
|
||||
extern crate nalgebra as na;
|
||||
|
||||
use alga::linear::Transformation;
|
||||
use na::{Matrix4, Point3, Vector3, Vector4};
|
||||
|
||||
fn main() {
|
||||
|
@ -282,7 +282,6 @@ pub fn perspective_fov_lh_no<N: Real>(fov: N, width: N, height: N, near: N, far:
|
||||
"The fov must be greater than zero"
|
||||
);
|
||||
|
||||
let zero = N::zero();
|
||||
let mut mat = TMat4::zeros();
|
||||
|
||||
let rad = fov;
|
||||
@ -522,7 +521,6 @@ pub fn perspective_lh_no<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<
|
||||
"The apsect ratio must not be zero."
|
||||
);
|
||||
|
||||
let zero = N::zero();
|
||||
let one = N::one();
|
||||
let two: N = ::convert( 2.0);
|
||||
let mut mat : TMat4<N> = TMat4::zeros();
|
||||
@ -559,7 +557,6 @@ pub fn perspective_lh_zo<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<
|
||||
"The apsect ratio must not be zero."
|
||||
);
|
||||
|
||||
let zero = N::zero();
|
||||
let one = N::one();
|
||||
let two: N = ::convert( 2.0);
|
||||
let mut mat: TMat4<N> = TMat4::zeros();
|
||||
@ -664,7 +661,6 @@ pub fn perspective_rh_zo<N: Real>(aspect: N, fovy: N, near: N, far: N) -> TMat4<
|
||||
);
|
||||
|
||||
let negone = -N::one();
|
||||
let zero = N::zero();
|
||||
let one = N::one();
|
||||
let two = ::convert( 2.0);
|
||||
let mut mat = TMat4::zeros();
|
||||
|
@ -33,5 +33,5 @@ pub fn quat_lerp<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
|
||||
pub fn quat_slerp<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
|
||||
Unit::new_normalize(*x)
|
||||
.slerp(&Unit::new_normalize(*y), a)
|
||||
.unwrap()
|
||||
.into_inner()
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ pub fn quat_pow<N: Real>(q: &Qua<N>, y: N) -> Qua<N> {
|
||||
|
||||
/// Builds a quaternion from an axis and an angle, and right-multiply it to the quaternion `q`.
|
||||
pub fn quat_rotate<N: Real>(q: &Qua<N>, angle: N, axis: &TVec3<N>) -> Qua<N> {
|
||||
q * UnitQuaternion::from_axis_angle(&Unit::new_normalize(*axis), angle).unwrap()
|
||||
q * UnitQuaternion::from_axis_angle(&Unit::new_normalize(*axis), angle).into_inner()
|
||||
}
|
||||
|
||||
//pub fn quat_sqrt<N: Real>(q: &Qua<N>) -> Qua<N> {
|
||||
|
@ -9,13 +9,13 @@ pub fn quat_angle<N: Real>(x: &Qua<N>) -> N {
|
||||
|
||||
/// Creates a quaternion from an axis and an angle.
|
||||
pub fn quat_angle_axis<N: Real>(angle: N, axis: &TVec3<N>) -> Qua<N> {
|
||||
UnitQuaternion::from_axis_angle(&Unit::new_normalize(*axis), angle).unwrap()
|
||||
UnitQuaternion::from_axis_angle(&Unit::new_normalize(*axis), angle).into_inner()
|
||||
}
|
||||
|
||||
/// The rotation axis of a quaternion assumed to be normalized.
|
||||
pub fn quat_axis<N: Real>(x: &Qua<N>) -> TVec3<N> {
|
||||
if let Some(a) = UnitQuaternion::from_quaternion(*x).axis() {
|
||||
a.unwrap()
|
||||
a.into_inner()
|
||||
} else {
|
||||
TVec3::zeros()
|
||||
}
|
||||
|
@ -47,12 +47,12 @@ pub fn quat_look_at<N: Real>(direction: &TVec3<N>, up: &TVec3<N>) -> Qua<N> {
|
||||
|
||||
/// Computes a left-handed look-at quaternion (equivalent to a left-handed look-at matrix).
|
||||
pub fn quat_look_at_lh<N: Real>(direction: &TVec3<N>, up: &TVec3<N>) -> Qua<N> {
|
||||
UnitQuaternion::look_at_lh(direction, up).unwrap()
|
||||
UnitQuaternion::look_at_lh(direction, up).into_inner()
|
||||
}
|
||||
|
||||
/// Computes a right-handed look-at quaternion (equivalent to a right-handed look-at matrix).
|
||||
pub fn quat_look_at_rh<N: Real>(direction: &TVec3<N>, up: &TVec3<N>) -> Qua<N> {
|
||||
UnitQuaternion::look_at_rh(direction, up).unwrap()
|
||||
UnitQuaternion::look_at_rh(direction, up).into_inner()
|
||||
}
|
||||
|
||||
/// The "roll" Euler angle of the quaternion `x` assumed to be normalized.
|
||||
|
@ -21,7 +21,7 @@ pub fn quat_extract_real_component<N: Real>(q: &Qua<N>) -> N {
|
||||
pub fn quat_fast_mix<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
|
||||
Unit::new_unchecked(*x)
|
||||
.nlerp(&Unit::new_unchecked(*y), a)
|
||||
.unwrap()
|
||||
.into_inner()
|
||||
}
|
||||
|
||||
//pub fn quat_intermediate<N: Real>(prev: &Qua<N>, curr: &Qua<N>, next: &Qua<N>) -> Qua<N> {
|
||||
@ -40,7 +40,7 @@ pub fn quat_magnitude2<N: Real>(q: &Qua<N>) -> N {
|
||||
|
||||
/// The quaternion representing the identity rotation.
|
||||
pub fn quat_identity<N: Real>() -> Qua<N> {
|
||||
UnitQuaternion::identity().unwrap()
|
||||
UnitQuaternion::identity().into_inner()
|
||||
}
|
||||
|
||||
/// Rotates a vector by a quaternion assumed to be normalized.
|
||||
@ -58,14 +58,14 @@ pub fn quat_rotate_vec<N: Real>(q: &Qua<N>, v: &TVec4<N>) -> TVec4<N> {
|
||||
pub fn quat_rotation<N: Real>(orig: &TVec3<N>, dest: &TVec3<N>) -> Qua<N> {
|
||||
UnitQuaternion::rotation_between(orig, dest)
|
||||
.unwrap_or_else(UnitQuaternion::identity)
|
||||
.unwrap()
|
||||
.into_inner()
|
||||
}
|
||||
|
||||
/// The spherical linear interpolation between two quaternions.
|
||||
pub fn quat_short_mix<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
|
||||
Unit::new_normalize(*x)
|
||||
.slerp(&Unit::new_normalize(*y), a)
|
||||
.unwrap()
|
||||
.into_inner()
|
||||
}
|
||||
|
||||
//pub fn quat_squad<N: Real>(q1: &Qua<N>, q2: &Qua<N>, s1: &Qua<N>, s2: &Qua<N>, h: N) -> Qua<N> {
|
||||
@ -76,7 +76,7 @@ pub fn quat_short_mix<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
|
||||
pub fn quat_to_mat3<N: Real>(x: &Qua<N>) -> TMat3<N> {
|
||||
UnitQuaternion::new_unchecked(*x)
|
||||
.to_rotation_matrix()
|
||||
.unwrap()
|
||||
.into_inner()
|
||||
}
|
||||
|
||||
/// Converts a quaternion to a rotation matrix in homogenous coordinates.
|
||||
@ -87,7 +87,7 @@ pub fn quat_to_mat4<N: Real>(x: &Qua<N>) -> TMat4<N> {
|
||||
/// Converts a rotation matrix to a quaternion.
|
||||
pub fn mat3_to_quat<N: Real>(x: &TMat3<N>) -> Qua<N> {
|
||||
let r = Rotation3::from_matrix_unchecked(*x);
|
||||
UnitQuaternion::from_rotation_matrix(&r).unwrap()
|
||||
UnitQuaternion::from_rotation_matrix(&r).into_inner()
|
||||
}
|
||||
|
||||
/// Converts a rotation matrix in homogeneous coordinates to a quaternion.
|
||||
|
@ -21,5 +21,5 @@ pub fn rotate_normalized_axis<N: Real>(m: &TMat4<N>, angle: N, axis: &TVec3<N>)
|
||||
/// * `angle` - Angle expressed in radians.
|
||||
/// * `axis` - Normalized axis of the rotation, must be normalized.
|
||||
pub fn quat_rotate_normalized_axis<N: Real>(q: &Qua<N>, angle: N, axis: &TVec3<N>) -> Qua<N> {
|
||||
q * UnitQuaternion::from_axis_angle(&Unit::new_unchecked(*axis), angle).unwrap()
|
||||
q * UnitQuaternion::from_axis_angle(&Unit::new_unchecked(*axis), angle).into_inner()
|
||||
}
|
||||
|
@ -60,5 +60,5 @@ pub fn rotate_z_vec4<N: Real>(v: &TVec4<N>, angle: N) -> TVec4<N> {
|
||||
pub fn slerp<N: Real>(x: &TVec3<N>, y: &TVec3<N>, a: N) -> TVec3<N> {
|
||||
Unit::new_unchecked(*x)
|
||||
.slerp(&Unit::new_unchecked(*y), a)
|
||||
.unwrap()
|
||||
.into_inner()
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use glm::Vec4;
|
||||
#[test]
|
||||
pub fn orthographic_glm_nalgebra_same()
|
||||
{
|
||||
let na_mat : Mat4 = Orthographic3::new(-100.0f32,100.0f32, -50.0f32, 50.0f32, 0.1f32, 100.0f32).unwrap();
|
||||
let na_mat : Mat4 = Orthographic3::new(-100.0f32,100.0f32, -50.0f32, 50.0f32, 0.1f32, 100.0f32).into_inner();
|
||||
let gl_mat : Mat4 = glm::ortho(-100.0f32,100.0f32, -50.0f32, 50.0f32, 0.1f32, 100.0f32);
|
||||
|
||||
assert_eq!(na_mat, gl_mat);
|
||||
@ -18,7 +18,7 @@ pub fn orthographic_glm_nalgebra_same()
|
||||
#[test]
|
||||
pub fn perspective_glm_nalgebra_same()
|
||||
{
|
||||
let na_mat : Mat4 = Perspective3::new(16.0f32/9.0f32, 3.14f32/2.0f32, 0.1f32, 100.0f32).unwrap();
|
||||
let na_mat : Mat4 = Perspective3::new(16.0f32/9.0f32, 3.14f32/2.0f32, 0.1f32, 100.0f32).into_inner();
|
||||
let gl_mat : Mat4 = glm::perspective(16.0f32/9.0f32, 3.14f32/2.0f32, 0.1f32, 100.0f32);
|
||||
|
||||
assert_eq!(na_mat, gl_mat);
|
||||
@ -29,7 +29,7 @@ pub fn orthographic_glm_nalgebra_project_same()
|
||||
{
|
||||
let point = Vec4::new(1.0,0.0,-20.0,1.0);
|
||||
|
||||
let na_mat : Mat4 = Orthographic3::new(-100.0f32,100.0f32, -50.0f32, 50.0f32, 0.1f32, 100.0f32).unwrap();
|
||||
let na_mat : Mat4 = Orthographic3::new(-100.0f32,100.0f32, -50.0f32, 50.0f32, 0.1f32, 100.0f32).into_inner();
|
||||
let gl_mat : Mat4 = glm::ortho(-100.0f32,100.0f32, -50.0f32, 50.0f32, 0.1f32, 100.0f32);
|
||||
|
||||
let na_pt = na_mat * point;
|
||||
@ -44,7 +44,7 @@ pub fn perspective_glm_nalgebra_project_same()
|
||||
{
|
||||
let point = Vec4::new(1.0,0.0,-20.0,1.0);
|
||||
|
||||
let na_mat : Mat4 = Perspective3::new(16.0f32/9.0f32, 3.14f32/2.0f32, 0.1f32, 100.0f32).unwrap();
|
||||
let na_mat : Mat4 = Perspective3::new(16.0f32/9.0f32, 3.14f32/2.0f32, 0.1f32, 100.0f32).into_inner();
|
||||
let gl_mat : Mat4 = glm::perspective(16.0f32/9.0f32, 3.14f32/2.0f32, 0.1f32, 100.0f32);
|
||||
|
||||
let na_pt = na_mat * point;
|
||||
|
@ -7,10 +7,9 @@ use rand::distributions::{Distribution, OpenClosed01, Standard};
|
||||
use rand::Rng;
|
||||
|
||||
use alga::general::Real;
|
||||
use base::allocator::Allocator;
|
||||
use base::dimension::{U1, U2};
|
||||
use base::storage::Storage;
|
||||
use base::{DefaultAllocator, Unit, Vector};
|
||||
use base::{Unit, Vector};
|
||||
use geometry::{Rotation2, UnitComplex};
|
||||
|
||||
impl<N: Real> UnitComplex<N> {
|
||||
|
@ -26,9 +26,9 @@ quickcheck!(
|
||||
relative_eq!(yaw * pitch * roll, rpy, epsilon = 1.0e-7)
|
||||
}
|
||||
|
||||
fn to_euler_angles(r: f64, p: f64, y: f64) -> bool {
|
||||
fn euler_angles(r: f64, p: f64, y: f64) -> bool {
|
||||
let rpy = UnitQuaternion::from_euler_angles(r, p, y);
|
||||
let (roll, pitch, yaw) = rpy.to_euler_angles();
|
||||
let (roll, pitch, yaw) = rpy.euler_angles();
|
||||
relative_eq!(UnitQuaternion::from_euler_angles(roll, pitch, yaw), rpy, epsilon = 1.0e-7)
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ fn angle_3() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn quaternion_to_euler_angles_issue_494() {
|
||||
fn quaternion_euler_angles_issue_494() {
|
||||
let quat = UnitQuaternion::from_quaternion(Quaternion::new(
|
||||
-0.10405792,
|
||||
-0.6993922f32,
|
||||
@ -55,17 +55,17 @@ mod quickcheck_tests {
|
||||
yaw * pitch * roll == rpy
|
||||
}
|
||||
|
||||
fn to_euler_angles(r: f64, p: f64, y: f64) -> bool {
|
||||
fn euler_angles(r: f64, p: f64, y: f64) -> bool {
|
||||
let rpy = Rotation3::from_euler_angles(r, p, y);
|
||||
let (roll, pitch, yaw) = rpy.to_euler_angles();
|
||||
let (roll, pitch, yaw) = rpy.euler_angles();
|
||||
relative_eq!(Rotation3::from_euler_angles(roll, pitch, yaw), rpy, epsilon = 1.0e-7)
|
||||
}
|
||||
|
||||
fn to_euler_angles_gimble_lock(r: f64, y: f64) -> bool {
|
||||
fn euler_angles_gimble_lock(r: f64, y: f64) -> bool {
|
||||
let pos = Rotation3::from_euler_angles(r, f64::frac_pi_2(), y);
|
||||
let neg = Rotation3::from_euler_angles(r, -f64::frac_pi_2(), y);
|
||||
let (pos_r, pos_p, pos_y) = pos.to_euler_angles();
|
||||
let (neg_r, neg_p, neg_y) = neg.to_euler_angles();
|
||||
let (pos_r, pos_p, pos_y) = pos.euler_angles();
|
||||
let (neg_r, neg_p, neg_y) = neg.euler_angles();
|
||||
relative_eq!(Rotation3::from_euler_angles(pos_r, pos_p, pos_y), pos, epsilon = 1.0e-7) &&
|
||||
relative_eq!(Rotation3::from_euler_angles(neg_r, neg_p, neg_y), neg, epsilon = 1.0e-7)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user