viewport origin vs. window origin 
Author Message
 viewport origin vs. window origin

Hello. I am reading Petzold"s Programming Window ( 5 edition).
These two formulas for the MM_TEXT mode determine how to
translate logical coordinates to device coordinates:
       xViewPort = xWindow - xWinOrg + xViewOrg
       yViewPort = yWindow - yWinOrg + yViewOrg

Petzold says on page 181: " Generally, you' ll use either SetViewportOrgEx
or SetWindowOrgEx but not both." Why the heck does Microsoft use two
variables for determining how to translate nWindow to nViewPort and at the
same time says that "you don't need to set both of them, setting either one
of
them will do"? Strange! Are there any special cases we could benefit from
by setting both the viewport origin and window origin?
Alan



Sun, 07 Sep 2003 07:34:28 GMT  
 viewport origin vs. window origin


Quote:
> Hello. I am reading Petzold"s Programming Window ( 5 edition).
> These two formulas for the MM_TEXT mode determine how to
> translate logical coordinates to device coordinates:
>        xViewPort = xWindow - xWinOrg + xViewOrg
>        yViewPort = yWindow - yWinOrg + yViewOrg

> Petzold says on page 181: " Generally, you' ll use either SetViewportOrgEx
> or SetWindowOrgEx but not both." Why the heck does Microsoft use two
> variables for determining how to translate nWindow to nViewPort and at the
> same time says that "you don't need to set both of them, setting either
one
> of
> them will do"? Strange! Are there any special cases we could benefit from
> by setting both the viewport origin and window origin?
> Alan

This is how Windows calculates the coordinates of a point that it should
draw on the screen:

X = (x - WindowOrg.x) * ViewportExt.cx / WindowExt.cx + ViewportOrg.x;
Y = (y - WindowOrg.y) * ViewportExt.cy / WindowExt.cy + ViewportOrg.y;

(X and Y are of course relative to the device context origin)

ViewportOrg and WindowOrg could be used interchangeably only if  ViewportExt
equals WindowExt. As you can see all variables in the equations are
relevant.
I wonder why the book doesn't simply provide this formula?

Of course, this has nothing to do with x86 assembly...

-tzvetan



Sun, 07 Sep 2003 22:26:19 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Sun vs. IBM and the origins of Swing

2. Java Origins in Objective-C and Smalltalk - by one of its authors

3. S-Plus, Origin or something else ? TRY J.

4. J and index-origin question.

5. Index Origin in GLEE

6. K.CoSy Edition 1 ( 0 origin ) now available

7. origin of arrays

8. APL problem - sorting a matrix without gagging in origin 0

9. Origin of right hand precedence in APL?

10. Curious about origin of J source

11. OO Origins

12. origin of the name Smalltalk

 

 
Powered by phpBB® Forum Software