Inverting transforms
You already know that a transform maps from one space into another space. It's possible to reverse that mapping and map the transform back into the original space. As with matrices and quaternions, transforms can also be inverted.
When inverting scale, keep in mind that 0 can't be inverted. The case where scale is 0 will need to be treated specially
Implement the inverse
transform method in Transform.cpp
. Don't forget to declare the method in Transform.h
:
Transform inverse(const Transform& t) { Transform inv; inv.rotation = inverse(t.rotation); inv.scale.x = fabs(t.scale.x) < VEC3_EPSILON ? 0.0f : 1.0f / t.scale.x; inv.scale.y = fabs(t.scale.y) < VEC3_EPSILON ? ...