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 ? Â Â Â Â Â Â Â Â Â Â Â ...