mirror of
https://github.com/servo/servo.git
synced 2025-08-12 17:05:33 +01:00
Never store a squared root in SquaredDistance
This commit is contained in:
parent
df079286c2
commit
6ce5e9a869
4 changed files with 27 additions and 31 deletions
|
@ -811,7 +811,7 @@ impl Animate for Visibility {
|
|||
impl ComputeSquaredDistance for Visibility {
|
||||
#[inline]
|
||||
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
|
||||
Ok(SquaredDistance::Value(if *self == *other { 0. } else { 1. }))
|
||||
Ok(SquaredDistance::from_sqrt(if *self == *other { 0. } else { 1. }))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1921,7 +1921,7 @@ impl ComputeSquaredDistance for Quaternion {
|
|||
// so we can get their angle difference by:
|
||||
// cos(theta/2) = (q1 dot q2) / (|q1| * |q2|) = q1 dot q2.
|
||||
let distance = self.dot(other).max(-1.0).min(1.0).acos() * 2.0;
|
||||
Ok(SquaredDistance::Value(distance * distance))
|
||||
Ok(SquaredDistance::from_sqrt(distance))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue