Skip to content

Commit

Permalink
Fix slurp not always taking shortest path (#153)
Browse files Browse the repository at this point in the history
* Fix slurp not always taking shortest path

* Apply suggestions from code review

Right, Rotor3 is Copy, didn't think about that

Co-authored-by: Gray Olson <gray@grayolson.com>

Co-authored-by: Gray Olson <gray@grayolson.com>
  • Loading branch information
G0BL1N and fu5ha authored Dec 27, 2022
1 parent bfdcd71 commit 045ed5e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/interp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ macro_rules! impl_slerp_rotor3 {
///
/// Note that you should often normalize the result returned by this operation, when working with `Rotor`s, etc!
#[inline]
fn slerp(&self, end: Self, t: $tt) -> Self {
let dot = self.dot(end);
fn slerp(&self, mut end: Self, t: $tt) -> Self {
let mut dot = self.dot(end);

// make sure interpolation takes shortest path in case dot product is negative
if dot < 0.0 {
end = end * -1.0;
dot = -dot;
}

if dot > 0.9995 {
return self.lerp(end, t);
Expand Down

0 comments on commit 045ed5e

Please sign in to comment.