use if/else if/else instead of match ()

It looks more idiomatic.
This commit is contained in:
Jonathan Neuschäfer 2015-03-14 04:09:29 +01:00
parent f4ac3952bd
commit bc8a47fb8d

View file

@ -1344,8 +1344,8 @@ impl<S: BaseFloat + 'static> ToQuaternion<S> for Matrix3<S> {
// http://www.cs.ucr.edu/~vbz/resources/quatut.pdf
let trace = self.trace();
let half: S = cast(0.5f64).unwrap();
match () {
() if trace >= zero::<S>() => {
if trace >= zero::<S>() {
let s = (one::<S>() + trace).sqrt();
let w = half * s;
let s = half / s;
@ -1353,8 +1353,7 @@ impl<S: BaseFloat + 'static> ToQuaternion<S> for Matrix3<S> {
let y = (self[2][0] - self[0][2]) * s;
let z = (self[0][1] - self[1][0]) * s;
Quaternion::new(w, x, y, z)
}
() if (self[0][0] > self[1][1]) && (self[0][0] > self[2][2]) => {
} else if (self[0][0] > self[1][1]) && (self[0][0] > self[2][2]) {
let s = (half + (self[0][0] - self[1][1] - self[2][2])).sqrt();
let w = half * s;
let s = half / s;
@ -1362,8 +1361,7 @@ impl<S: BaseFloat + 'static> ToQuaternion<S> for Matrix3<S> {
let y = (self[2][0] - self[0][2]) * s;
let z = (self[1][2] - self[2][1]) * s;
Quaternion::new(w, x, y, z)
}
() if self[1][1] > self[2][2] => {
} else if self[1][1] > self[2][2] {
let s = (half + (self[1][1] - self[0][0] - self[2][2])).sqrt();
let w = half * s;
let s = half / s;
@ -1371,8 +1369,7 @@ impl<S: BaseFloat + 'static> ToQuaternion<S> for Matrix3<S> {
let y = (self[1][2] - self[2][1]) * s;
let z = (self[2][0] - self[0][2]) * s;
Quaternion::new(w, x, y, z)
}
() => {
} else {
let s = (half + (self[2][2] - self[0][0] - self[1][1])).sqrt();
let w = half * s;
let s = half / s;
@ -1383,7 +1380,6 @@ impl<S: BaseFloat + 'static> ToQuaternion<S> for Matrix3<S> {
}
}
}
}
impl<S: BaseNum> fmt::Debug for Matrix2<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {