| Consider the problem of converting between coordinate systems. In the domain of printed circuit board design, millimeters are the appropriate unit of measure, but the pc board design must be displayed on a monitor whose pixels do not measure in millimeters and are not square. To complicate things further, the user wants to view the design at 173% actual size. | |
| This problem is one of moving from a world coordinate system (millimeter) to a screen-coordinate system (pixels). This problem can be solved by a combination of translations and scaling. The viewed area is called the window in the world-coordinate system and the viewport in screen coordinates. To translate from the world coordinate system to the screen-coordinate system, we can apply a number of transformations to the viewed area. First, translate the viewed area in the world-coordinates (the window) to the origin. Then scale the viewed area to the size of the viewport in the screen coordinate system. Finally, translate the space to the correct location in the screen coordinates (viewport). | |
The transformation can be represented in the general form: or:
| |
In order to translate from one coordinate system to another, we want
to input individual coordinates from the world system and output
the translated coordinates in the screen system. Thus, for the coordinate (20,17) in the world coordinate system, we get: This process could be repeated for each of the coordinates representing the p-c board, but applying general transformations turns out to waste considerable time. Each transformation requires a 3x3 matrix multiplication which is composed of 9 additions and 9 multiplications (after divisions and subtractions are pre-computed). By simplifying the general case, we can reduce the work needed per coordinate. | |
Is a simplified form of the general case. By plugging in the values for the world to screen coordinate transformation described above, we can write the equation as: | |