fu5ha/ultraviolet

Rotor2 do not rotate...

Closed this issue · 2 comments

Quoting https://github.com/termhn/ultraviolet/blob/master/src/rotor.rs

            /// Rotates a vector by this rotor.
            ///
            /// `self` *must* be normalized!
            #[inline]
            pub fn rotate_vec(self, vec: &mut $vt) {
                let fx = self.s * vec.x + self.bv.xy * vec.y;
                let fy = self.s * vec.y - (self.bv.xy * vec.x);

                vec.x = self.s * fx - (self.bv.xy * fy);
                vec.y = self.s * fy + self.bv.xy * fx;
            }

If I call s = self.s, b = self.bv.xy, then vec.x becomes

vec.x = s * fx - b * fy
vec.x = s * s * vec.x + s*b * vec.y - b * s * vec.y + b * b * vec.x 
vec.x = self.mag() * vec.x

Which is definitely not what we want.. I don't know what the correct formula is however

fu5ha commented

Fixed by #88

fu5ha commented

Also released in 0.7.5 @thenlevy @austinliew