use if
/else if
/else
instead of match ()
It looks more idiomatic.
This commit is contained in:
parent
f4ac3952bd
commit
bc8a47fb8d
1 changed files with 33 additions and 37 deletions
|
@ -1344,43 +1344,39 @@ impl<S: BaseFloat + 'static> ToQuaternion<S> for Matrix3<S> {
|
||||||
// http://www.cs.ucr.edu/~vbz/resources/quatut.pdf
|
// http://www.cs.ucr.edu/~vbz/resources/quatut.pdf
|
||||||
let trace = self.trace();
|
let trace = self.trace();
|
||||||
let half: S = cast(0.5f64).unwrap();
|
let half: S = cast(0.5f64).unwrap();
|
||||||
match () {
|
|
||||||
() if trace >= zero::<S>() => {
|
if trace >= zero::<S>() {
|
||||||
let s = (one::<S>() + trace).sqrt();
|
let s = (one::<S>() + trace).sqrt();
|
||||||
let w = half * s;
|
let w = half * s;
|
||||||
let s = half / s;
|
let s = half / s;
|
||||||
let x = (self[1][2] - self[2][1]) * s;
|
let x = (self[1][2] - self[2][1]) * s;
|
||||||
let y = (self[2][0] - self[0][2]) * s;
|
let y = (self[2][0] - self[0][2]) * s;
|
||||||
let z = (self[0][1] - self[1][0]) * s;
|
let z = (self[0][1] - self[1][0]) * s;
|
||||||
Quaternion::new(w, x, y, z)
|
Quaternion::new(w, x, y, z)
|
||||||
}
|
} else if (self[0][0] > self[1][1]) && (self[0][0] > self[2][2]) {
|
||||||
() 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 s = (half + (self[0][0] - self[1][1] - self[2][2])).sqrt();
|
let w = half * s;
|
||||||
let w = half * s;
|
let s = half / s;
|
||||||
let s = half / s;
|
let x = (self[0][1] - self[1][0]) * s;
|
||||||
let x = (self[0][1] - self[1][0]) * s;
|
let y = (self[2][0] - self[0][2]) * s;
|
||||||
let y = (self[2][0] - self[0][2]) * s;
|
let z = (self[1][2] - self[2][1]) * s;
|
||||||
let z = (self[1][2] - self[2][1]) * s;
|
Quaternion::new(w, x, y, z)
|
||||||
Quaternion::new(w, x, y, z)
|
} else if self[1][1] > self[2][2] {
|
||||||
}
|
let s = (half + (self[1][1] - self[0][0] - self[2][2])).sqrt();
|
||||||
() if self[1][1] > self[2][2] => {
|
let w = half * s;
|
||||||
let s = (half + (self[1][1] - self[0][0] - self[2][2])).sqrt();
|
let s = half / s;
|
||||||
let w = half * s;
|
let x = (self[0][1] - self[1][0]) * s;
|
||||||
let s = half / s;
|
let y = (self[1][2] - self[2][1]) * s;
|
||||||
let x = (self[0][1] - self[1][0]) * s;
|
let z = (self[2][0] - self[0][2]) * s;
|
||||||
let y = (self[1][2] - self[2][1]) * s;
|
Quaternion::new(w, x, y, z)
|
||||||
let z = (self[2][0] - self[0][2]) * s;
|
} else {
|
||||||
Quaternion::new(w, x, y, z)
|
let s = (half + (self[2][2] - self[0][0] - self[1][1])).sqrt();
|
||||||
}
|
let w = half * s;
|
||||||
() => {
|
let s = half / s;
|
||||||
let s = (half + (self[2][2] - self[0][0] - self[1][1])).sqrt();
|
let x = (self[2][0] - self[0][2]) * s;
|
||||||
let w = half * s;
|
let y = (self[1][2] - self[2][1]) * s;
|
||||||
let s = half / s;
|
let z = (self[0][1] - self[1][0]) * s;
|
||||||
let x = (self[2][0] - self[0][2]) * s;
|
Quaternion::new(w, x, y, z)
|
||||||
let y = (self[1][2] - self[2][1]) * s;
|
|
||||||
let z = (self[0][1] - self[1][0]) * s;
|
|
||||||
Quaternion::new(w, x, y, z)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue