fu5ha / ultraviolet

A wide linear algebra crate for games and graphics.
https://crates.io/crates/ultraviolet
750 stars 81 forks source link

Rotor2 do not rotate... #85

Closed thenlevy closed 4 years ago

thenlevy commented 4 years ago

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 4 years ago

Fixed by #88

fu5ha commented 4 years ago

Also released in 0.7.5 @thenlevy @austinliew