rustgd / cgmath

A linear algebra and mathematics library for computer graphics.
https://docs.rs/cgmath
Apache License 2.0
1.12k stars 155 forks source link

Basis2::look_at and Matrix2::look_at are incorrect #489

Closed blargg closed 5 years ago

blargg commented 5 years ago

It seems like the definition for these lookat functions are incorrect. The functions only produce an ortho-nomal basis if the vectors passed in are already an ortho-normal basis. It doesn't seem like this should be a requirement, since Matrix3::look_at does not have this requirement. Matrix3 will do all the math to make a basis out of the inputs.

It also seems like we should not need to use the up vector at all for the 2d case. We should be able to determine an angle of rotation using only the look at vector, which is enough to determine the Basis2.

blargg commented 5 years ago

I looked at the math for this, it was simpler and more numerically stable than I first thought. I added a PR for it #491.

blargg commented 5 years ago

PR merged, closing.