Coordinate transform stretching

When changing coordinate system one has to be careful in many situations about the "shape" of the coordinate space. You can see this in all kind of applications dealing with differentiation and integration.

The Shadertoy demo (https://www.shadertoy.com/view/7stGzN) shows, why this is needed. Basically, the amount of volume that a small parameter region in one space takes up, might be drastically different in another one, into which the parameters where transformed into. The demo transforms a grid from a common Cartesian space into some other space via a generally non-linear transformation functions, which means that the amount of stretching and squishing changes depending on where the corresponding point is.

As shadertoy embeds don't seem to work anymore, here is a video of the shader:

The shader uses my automatic differentiation pack for GLSL (https://github.com/sibaku/glsl-autodiff). Basically, this computes derivatives of expressions by wrapping each operation and adding a bit of additional data to each number. The nice thing is, that it is exact minus numerical precision without too much overhead. This is in stark contrast to numerical differentiation, but requires implementing all operations using custom types (much easier in languages with operator overloading).

The demo computes the Jacobian of the transform, which transforms the grid from its base positions to the right side shape (for technical reasons for the visualizations, we compute J1|\mathbf{J}^{-1}|, but J1=1J|\mathbf{J}^{-1}| = \frac{1}{|\mathbf{J}}|, so we can easily recover the original value). This Jacobian, more specifically, its determinant is a measure of how much space around a point gets compressed or stretched. This factor is used to color each point, with blue showing squishing and red stretching.