Hacker News new | ask | show | jobs
by alipang 1435 days ago
This is a really intuitive way of thinking about it. The best way I could work this out was to start with the special case of pure scaling in a single direction.

For instance when scaling by "a" in the x direction

M = (a 0; 0 1)

It's pretty easy to see by graphing an example that in order for the normal to work out correctly you must scale it by the inverse scale factor (1 / a), so the correct choice of M is the inverse, M⁻¹, i.e. M = ((1 /a) 0; 0 1).

This of course generalises to scaling in multiple directions (just multiply the matrices) - i.e. to diagonal matrices. For

M = (a 0; 0 b)

the correct choice for transforming the normals is

M = ((1/a) 0; 0 (1/b));

By applying singular value decomposition you get

M = UDV

So choosing M' = M⁻¹ᵀ you'll get M' = (UDV)⁻¹ᵀ = UD⁻¹V

Since orthogonal matrices U, V will actually correctly transform the normals (they're rotations or reflections) you can intuitively understand that M' will work for transforming the normals.

Question is - where does the transpose part actually come from? It's a of a bit "magic" choice. This article makes it very clear that this "arises from" the transpose in the dot product, (t⋅n = tᵀn), as the dot product defines orthogonality!