rustgd / cgmath

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

Adding inverse transformation of a vector to the Transform trait. #431

Closed Rhuagh closed 7 years ago

Rhuagh commented 7 years ago

This is heavily used in collision detection. It's much cheaper to do the inverse transform of a ray/support function direction vector/etc, than to transform all the vertices of a primitive/complex shape.

We've found ourselves writing: transform.inverse_transform().and_then(|inverse| Some(inverse.transform_vector(some_vec))) over and over, so we felt there was a solid use case for having this in cgmath. It is also something that specific implementations of the Transform trait can do a much better version of than doing the full inverse of the transform, since vector space has no concept of translation.

brendanzab commented 7 years ago

Looks good! Let me know your thoughts on the my question. If you're cool with it, I'll merge.