If I have some node rendering tree set up, where a node basically has a draw method to render things, and a transform, represented as a 3x3 matrix, with scale and translation.

Now, I would like to constrain the scale and translation of that node (constrain the transform basically) to the bounds of the child. So if the child is a 300x400 image, I want the root to only scale large enough to see the whole image, not more. So does the translation, that it does not go beyond the image bounds. How can I achieve that? Which sorcery of mathematics must I read about to learn this? Affine transforms or what?

  • \$\begingroup\$ OK, I am just guesstimating, but it seems like I am looking to "normalize" the translation by removing the scaling. Then I can check that "pure" translation against my constraint... Easier said than done, though.. How can I reverse the scale effect. Multiply by which inverse matrix? \$\endgroup\$ – Mazyod Jul 23 '13 at 0:57
  • \$\begingroup\$ This question helped me resolve my issue: gamedev.stackexchange.com/questions/34262/… \$\endgroup\$ – Mazyod Jul 23 '13 at 16:39

Your Answer

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

Browse other questions tagged or ask your own question.