Let's say I needed to render an image at 1920 x 1080 and also at 1024 x 768. Instead of drawing two separate images, it might make sense to draw the scene in a common "virtual" coordinate system and then translate that to the appropriate output coordinate system.

Is there a name for this problem? I'm having a hard time figuring out what to start searching for.

  • $\begingroup$ Exactly. I would have a virtual coordinate system of my own definition, where the axis were -1 to 1 or 0 to 100 or whatever. Something small and easy to visualize in your head. This coordinate system isn't concerned with the physical limitations of "pixels" either. So a "half-pixel" is possible here. Once I've drawn each vertex in this "virtual" coordinate system I would then translate each one into any user defined resolution, for example a 1080p display. $\endgroup$ – Eric Aug 27 '16 at 14:29
  • $\begingroup$ What exactly do you mean by translate coordinates? Could you attach some image? $\endgroup$ – Evil Aug 28 '16 at 0:16

I'll try to answer my own question. The solution is an application of matrix transformations.

This lecture tries to explain some of the maths.


I think what I need to do is apply both a translation and scale matrix to each vertex in the "virtual" coordinate system to get them into the "physical" coordinate system.

Still trying to get my head around exactly how to do that.

| cite | improve this answer | |
  • 1
    $\begingroup$ Why do you need translate? Seriously, take [0-1] normalized coordinates in your virtual scene and then multiply by width or height of the actual scene. Quite straightforward. Imagine the center, with coordinates 0.5, 0.5 - in the first scene it will be 0.5 * 1920, 0.5 * 1080 and in the second 0.5 * 1024, 0.5 * 768. 0,0 will be the left top corner, 1.0 will be bottom right corner. $\endgroup$ – Evil Aug 27 '16 at 23:28
  • $\begingroup$ Maybe you have some special requirements, but if you simply divide by current scene width you get your X in range [0:1] then multiply by second scene width - you get the vertex transfered to the second scene. $\endgroup$ – Evil Aug 27 '16 at 23:43
  • $\begingroup$ The only missing point is aspect ratio - if objects looks too stretched - it would be nice to get closer to original one. It would be nice if you could tell what is your question about exactly, how do you plan to use it. In the answer it is not good to write doubts about the question. You may also enter the chat and ask there. $\endgroup$ – Evil Aug 27 '16 at 23:53
  • $\begingroup$ Got it jsfiddle.net/bbz5s183/1. $\endgroup$ – Eric Aug 28 '16 at 0:25
  • 1
    $\begingroup$ Please write up your approach in more detail. Chances are that that'll help you as well. $\endgroup$ – Raphael Sep 27 '16 at 7:40

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.