cargo fmt
This commit is contained in:
parent
fb205c0fc9
commit
575c458705
4 changed files with 38 additions and 22 deletions
|
@ -31,9 +31,9 @@ use euler::Euler;
|
||||||
use matrix::{Matrix3, Matrix4};
|
use matrix::{Matrix3, Matrix4};
|
||||||
use num::BaseFloat;
|
use num::BaseFloat;
|
||||||
use point::Point3;
|
use point::Point3;
|
||||||
|
use quaternion;
|
||||||
use rotation::{Basis3, Rotation, Rotation3};
|
use rotation::{Basis3, Rotation, Rotation3};
|
||||||
use vector::Vector3;
|
use vector::Vector3;
|
||||||
use quaternion;
|
|
||||||
|
|
||||||
#[cfg(feature = "mint")]
|
#[cfg(feature = "mint")]
|
||||||
use mint;
|
use mint;
|
||||||
|
@ -542,7 +542,7 @@ impl<S: BaseFloat> From<Quaternion<S>> for [S; 4] {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(v: Quaternion<S>) -> Self {
|
fn from(v: Quaternion<S>) -> Self {
|
||||||
let (xi, yj, zk, w) = v.into();
|
let (xi, yj, zk, w) = v.into();
|
||||||
[xi, yj, zk, w]
|
[xi, yj, zk, w]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,10 +584,10 @@ impl<'a, S: BaseFloat> From<&'a mut [S; 4]> for &'a mut Quaternion<S> {
|
||||||
impl<S: BaseFloat> From<Quaternion<S>> for (S, S, S, S) {
|
impl<S: BaseFloat> From<Quaternion<S>> for (S, S, S, S) {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(v: Quaternion<S>) -> Self {
|
fn from(v: Quaternion<S>) -> Self {
|
||||||
let Quaternion {
|
let Quaternion {
|
||||||
s,
|
s,
|
||||||
v: Vector3 { x, y, z },
|
v: Vector3 { x, y, z },
|
||||||
} = v;
|
} = v;
|
||||||
(x, y, z, s)
|
(x, y, z, s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,8 @@ pub trait Transform<P: EuclideanSpace>: Sized + One {
|
||||||
|
|
||||||
/// Inverse transform a vector using this transform
|
/// Inverse transform a vector using this transform
|
||||||
fn inverse_transform_vector(&self, vec: P::Diff) -> Option<P::Diff> {
|
fn inverse_transform_vector(&self, vec: P::Diff) -> Option<P::Diff> {
|
||||||
self.inverse_transform().map(|inverse| inverse.transform_vector(vec))
|
self.inverse_transform()
|
||||||
|
.map(|inverse| inverse.transform_vector(vec))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transform a point using this transform.
|
/// Transform a point using this transform.
|
||||||
|
|
|
@ -733,11 +733,14 @@ pub mod matrix3 {
|
||||||
let up = Vector3::unit_y();
|
let up = Vector3::unit_y();
|
||||||
let m = Matrix3::look_to_lh(dir, up);
|
let m = Matrix3::look_to_lh(dir, up);
|
||||||
|
|
||||||
assert_ulps_eq!(m, Matrix3::from([
|
assert_ulps_eq!(
|
||||||
[0.9486833, -0.16903085, 0.26726127],
|
m,
|
||||||
[0.0, 0.8451542, 0.53452253],
|
Matrix3::from([
|
||||||
[-0.31622776, -0.50709254, 0.8017838_f32]
|
[0.9486833, -0.16903085, 0.26726127],
|
||||||
]));
|
[0.0, 0.8451542, 0.53452253],
|
||||||
|
[-0.31622776, -0.50709254, 0.8017838_f32]
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
{
|
{
|
||||||
|
@ -751,11 +754,14 @@ pub mod matrix3 {
|
||||||
let up = Vector3::unit_y();
|
let up = Vector3::unit_y();
|
||||||
let m = Matrix3::look_to_rh(dir, up);
|
let m = Matrix3::look_to_rh(dir, up);
|
||||||
|
|
||||||
assert_ulps_eq!(m, Matrix3::from([
|
assert_ulps_eq!(
|
||||||
[-0.9486833, -0.16903085, -0.26726127],
|
m,
|
||||||
[0.0, 0.8451542, -0.53452253],
|
Matrix3::from([
|
||||||
[0.31622776, -0.50709254, -0.8017838_f32]
|
[-0.9486833, -0.16903085, -0.26726127],
|
||||||
]));
|
[0.0, 0.8451542, -0.53452253],
|
||||||
|
[0.31622776, -0.50709254, -0.8017838_f32]
|
||||||
|
])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1174,7 +1180,7 @@ pub mod matrix4 {
|
||||||
[-0.9486833, -0.16903086, -0.26726127, 0.0],
|
[-0.9486833, -0.16903086, -0.26726127, 0.0],
|
||||||
[0.0, 0.84515435, -0.53452253, 0.0],
|
[0.0, 0.84515435, -0.53452253, 0.0],
|
||||||
[0.31622776, -0.5070926, -0.8017838, 0.0],
|
[0.31622776, -0.5070926, -0.8017838, 0.0],
|
||||||
[3.1622782, -0.84515476, 26.726126, 1.0_f32]
|
[3.1622782, -0.84515476, 26.726126, 1.0_f32],
|
||||||
]);
|
]);
|
||||||
assert_ulps_eq!(expected, m);
|
assert_ulps_eq!(expected, m);
|
||||||
|
|
||||||
|
@ -1194,7 +1200,7 @@ pub mod matrix4 {
|
||||||
[0.9486833, -0.16903086, 0.26726127, 0.0],
|
[0.9486833, -0.16903086, 0.26726127, 0.0],
|
||||||
[0.0, 0.84515435, 0.53452253, 0.0],
|
[0.0, 0.84515435, 0.53452253, 0.0],
|
||||||
[-0.31622776, -0.5070926, 0.8017838, 0.0],
|
[-0.31622776, -0.5070926, 0.8017838, 0.0],
|
||||||
[-3.1622782, -0.84515476, -26.726126, 1.0_f32]
|
[-3.1622782, -0.84515476, -26.726126, 1.0_f32],
|
||||||
]);
|
]);
|
||||||
assert_ulps_eq!(expected, m);
|
assert_ulps_eq!(expected, m);
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,10 @@ fn test_look_at() {
|
||||||
let center = Point3::new(0.0f64, 0.0, 0.0);
|
let center = Point3::new(0.0f64, 0.0, 0.0);
|
||||||
let up = Vector3::new(1.0f64, 0.0, 0.0);
|
let up = Vector3::new(1.0f64, 0.0, 0.0);
|
||||||
let t: Decomposed<Vector3<f64>, Quaternion<f64>> = Transform::look_at(eye, center, up);
|
let t: Decomposed<Vector3<f64>, Quaternion<f64>> = Transform::look_at(eye, center, up);
|
||||||
assert_ulps_eq!(t, Decomposed::<Vector3<f64>, Quaternion<f64>>::look_at(eye, center, up));
|
assert_ulps_eq!(
|
||||||
|
t,
|
||||||
|
Decomposed::<Vector3<f64>, Quaternion<f64>>::look_at(eye, center, up)
|
||||||
|
);
|
||||||
let point = Point3::new(1.0f64, 0.0, 0.0);
|
let point = Point3::new(1.0f64, 0.0, 0.0);
|
||||||
let view_point = Point3::new(0.0f64, 1.0, 5.0);
|
let view_point = Point3::new(0.0f64, 1.0, 5.0);
|
||||||
assert_ulps_eq!(&t.transform_point(point), &view_point);
|
assert_ulps_eq!(&t.transform_point(point), &view_point);
|
||||||
|
@ -106,7 +109,10 @@ fn test_look_at_lh() {
|
||||||
let center = Point3::new(0.0f64, 0.0, 0.0);
|
let center = Point3::new(0.0f64, 0.0, 0.0);
|
||||||
let up = Vector3::new(1.0f64, 0.0, 0.0);
|
let up = Vector3::new(1.0f64, 0.0, 0.0);
|
||||||
let t: Decomposed<Vector3<f64>, Quaternion<f64>> = Transform::look_at_lh(eye, center, up);
|
let t: Decomposed<Vector3<f64>, Quaternion<f64>> = Transform::look_at_lh(eye, center, up);
|
||||||
assert_ulps_eq!(t, Decomposed::<Vector3<f64>, Quaternion<f64>>::look_at_lh(eye, center, up));
|
assert_ulps_eq!(
|
||||||
|
t,
|
||||||
|
Decomposed::<Vector3<f64>, Quaternion<f64>>::look_at_lh(eye, center, up)
|
||||||
|
);
|
||||||
let point = Point3::new(1.0f64, 0.0, 0.0);
|
let point = Point3::new(1.0f64, 0.0, 0.0);
|
||||||
let view_point = Point3::new(0.0f64, 1.0, 5.0);
|
let view_point = Point3::new(0.0f64, 1.0, 5.0);
|
||||||
assert_ulps_eq!(&t.transform_point(point), &view_point);
|
assert_ulps_eq!(&t.transform_point(point), &view_point);
|
||||||
|
@ -129,7 +135,10 @@ fn test_look_at_rh() {
|
||||||
let center = Point3::new(0.0f64, 0.0, 0.0);
|
let center = Point3::new(0.0f64, 0.0, 0.0);
|
||||||
let up = Vector3::new(1.0f64, 0.0, 0.0);
|
let up = Vector3::new(1.0f64, 0.0, 0.0);
|
||||||
let t: Decomposed<Vector3<f64>, Quaternion<f64>> = Transform::look_at_rh(eye, center, up);
|
let t: Decomposed<Vector3<f64>, Quaternion<f64>> = Transform::look_at_rh(eye, center, up);
|
||||||
assert_ulps_eq!(t, Decomposed::<Vector3<f64>, Quaternion<f64>>::look_at_rh(eye, center, up));
|
assert_ulps_eq!(
|
||||||
|
t,
|
||||||
|
Decomposed::<Vector3<f64>, Quaternion<f64>>::look_at_rh(eye, center, up)
|
||||||
|
);
|
||||||
let point = Point3::new(1.0f64, 0.0, 0.0);
|
let point = Point3::new(1.0f64, 0.0, 0.0);
|
||||||
let view_point = Point3::new(0.0f64, 1.0, -5.0);
|
let view_point = Point3::new(0.0f64, 1.0, -5.0);
|
||||||
assert_ulps_eq!(&t.transform_point(point), &view_point);
|
assert_ulps_eq!(&t.transform_point(point), &view_point);
|
||||||
|
|
Loading…
Reference in a new issue