Calculate possible translation for quad to prevent leaving renderer window

Hey there!

Could anybody explain me the logic behind quad translation, please?
I have a quad which can be transformed with various scale factors (AspectRatio --> Uniform Scale).
Besides that there can be a translation on the x- or y-axis. However I do not want the quad to leave the renderer window. Not even partially.

As you know, the possible translation depends on the scale factor. The higher the scale factor, the smaller the possible translation.

What is the easiest way to calculate the maximum possible translation, with the scale factor as input?

I assume it’s a mathematical issue – this had always been my weak spot.

Don’t know if it is the easiest way, just the first thing I came up with…
Should at least give you some idea how to do it.

MaxTranslate.v4p (19.8 kB)

Wow! Thank you! This is impressive.