Expected purpose of 'PMAP':
-
'PMAP' allows to convert the coordinates modified by
'WINDOW' into coordinates in the current viewport, and vice versa.
- The current viewport can be either the declared graphics screen, or only a clipping region in the graphics screen when this one is declared by
'VIEW'.
- In all cases, the minimum coordinate value (xvmin or yvmin) in the current viewport is 0, and the maximum coordinate (xvmax or yvmax) is the offset value of the last pixel of the current viewport relative to the first of the current viewport.
- Example for
'SCREENRES width, height': xvmin=yvmin=0, xvmax=width-1, yvmax=height-1.
- Example for
'VIEW (x1, y1) - (x2, y2)': xvmin=yvmin=0, xvmax=x2-x1, yvmax=y2-y1.
- The modified coordinates declared by
'WINDOW SCREEN (xwmin, ywmin) - (xwmax, ywmax)' can be positive or negative, and xwmin corresponds to xvmin (0), ywmin corresponds to yvmin (0), xwmax corresponds to xvmax, ywmax corresponds to yvmax.
1)
It is preferable to use
'Window Screen' (y coordinates increasing from top to bottom), easier to analyze with your example (
'View (10, 10) - (100, 100)').
2)
No graphic plotting problem between the different mappings (
'ScreenRes' mapping, then
'View' mapping, then
'Window Screen' mapping):
Code: Select all
ScreenRes 500, 500 '' 'ScreenRes' mapping
Pset (10, 10) '' point #1
Pset (55, 55) '' point #2
Pset (100, 100) '' point #3
View (10, 10) - (100, 100) '' 'View' mapping
Pset (0, 0) '' point superimposed well at point #1
Pset (45, 45) '' point superimposed well at point #2
Pset (90, 90) '' point superimposed well at point #3
Window Screen (0, 0) - (9, 9) '' 'Window Screen' mapping
Pset (0, 0) '' point superimposed well at point #1
Pset (4.5, 4.5) '' point superimposed well at point #2
Pset (9, 9) '' point superimposed well at point #3
Sleep
- The points: (10, 10) in the
'ScreenRes' mapping, (0, 0) in the
'View' mapping, and (0, 0) in the
'Window Screen' mapping all overlap well.
- The points: (55, 55) in the
'ScreenRes' mapping, (45, 45) in the
'View' mapping, and (4.5, 4.5) in the
'Window Screen' mapping all overlap well.
- The points: (100, 100) in the
'ScreenRes' mapping, (90, 90) in the
'View' mapping, and (9, 9) in the
'Window Screen' mapping all overlap well.
3)
But it seems to me that there is a "bug?" (IMHO) in the 'Pmap' function only, that adds +1 pixel offset for the max value.
Maybe confusion between number of pixels (100 - 10 + 1 = 91) of the viewport, and number of intervals between pixels (100 - 10 = 90).
Code: Select all
ScreenRes 500, 500
View (10, 10) - (100, 100)
Window Screen (0, 0) - (9, 9)
Print "Logical x=0, Physical x="; PMap(0, 0) '' Expected 0, result: 0 => OK
Print "Logical y=0, Physical y="; PMap(0, 1) '' Expected 0, result: 0 => OK
Print "Logical x=4.5, Physical x="; PMap(4.5, 0) '' Expected 45, result: 45.5 => NOK
Print "Logical y=4.5, Physical y="; PMap(4.5, 1) '' Expected 45, result: 45.5 => NOK
Print "Logical x=9, Physical x="; PMap(9, 0) '' Expected 90, result: 91 => NOK
Print "Logical y=9, Physical y="; PMap(9, 1) '' Expected 90, result: 91 => NOK
Print "Physical x=0, Logical x="; PMap(0, 2) '' Expected 0, result: 0 => OK
Print "Physical y=0, Logical y="; PMap(0, 3) '' Expected 0, result: 0 => NOK
Print "Physical x=45, Logical x="; PMap(45, 2) '' Expected 4.5, result: 4.45055 => NOK
Print "Physical y=45, Logical y="; PMap(45, 3) '' Expected 4.5, result: 4.45055 => NOK
Print "Physical x=45.5, Logical x="; PMap(45.5, 2) '' Expected 9/90*45.5, result: 4.5 => NOK
Print "Physical y=45.5, Logical y="; PMap(45.5, 3) '' Expected 9/90*45.5, result: 4.5 => NOK
Print "Physical x=90, Logical x="; PMap(90, 2) '' Expected 9, result: 8.901099 => NOK
Print "Physical y=90, Logical y="; PMap(90, 3) '' Expected 9, result: 8.901099 => NOK
Print "Physical x=91, Logical x="; PMap(91, 2) '' Expected 9/90*91, result: 9 => NOK
Print "Physical y=91, Logical y="; PMap(91, 3) '' Expected 9/90*91, result: 9 => NOK
Sleep
See also the
PMAP documentation' example:
Code: Select all
ScreenRes 640, 480
Window Screen (0, 0)-(100, 100)
Print "Logical x=50, Physical x="; PMap(50, 0) '' 320 => NOK IMHO: 639/2 expected instead
Print "Logical y=50, Physical y="; PMap(50, 1) '' 240 => NOK IMHO: 479/2 expected instead
Print "Physical x=160, Logical x="; PMap(160, 2) '' 25 => NOK IMHO: 100/639*160 expected instead
Print "Physical y=60, Logical y="; PMap(60, 3) '' 12.5 => NOK IMHO: 100/479*60 expected instead
Sleep
Jeff, what is your opinion ?
(I wait a bit before filling in a bug report from this post)