My common task is I have a rect with coordinates of its $2$ points: $(x, y, z), (x + a, y + b, z)$. I applied a $4\times4$ transform matrix to it and it became a quadrilateral. Now for some reasons I can't use it this way and must apply scaling before other transformations. The list of operations is given below (it is used in computer graphics so I don't know exactly if it is a correct order or if it should be reversed). How to solve this issue?

  1. perspective (m34 = -0.0001);
  2. translation by z = -radius;
  3. rotation around x axis;
  4. rotation around y axis;
  5. scale (decrease the size);
  6. translation by z = radius.

This $4\times4$ matrix is transposed (for example, m41 means translation by x, m42 translation by y and m43 translation by z).


I multiply by additional matrices to "neutralize" perspective and translation (first 2 transforms) one by one then I apply scale (because the rotation and scale transforms don't need to be placed in a strict order). Then I "repeat" first 2 transforms I previously "removed".

The reason I haven't found a solution previously is the perspective transform. It seems it breaks the whole matrix (or adds something like an unusual distortion) and common matrix rules may work no longer. In this case my way works if I "remove" the perspective by the first action and it won't work if I "remove" transforms from the end of the sequence.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.