Mapping Relative Screen Coordinates to Pixels

A viewport transform maps a coordinate rectangle to an image's dimensions, with a convention for pixel centers and axis direction.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Trace a normalized range
  2. Test a boundary

Trace a normalized range

If x from zero to one maps continuously across width 200, x=0.25 lies at continuous position 50. Picking a pixel index further requires a rounding and boundary rule. See pixel coordinate conventions.

Test a boundary

The continuous endpoint at 200 does not itself name an index within a 200-pixel row. Zero-based indexing identifies the valid discrete range.[1]

References

  1. Matt Pharr, Wenzel Jakob and Greg Humphreys, Physically Based Rendering ↩