Tables for
Volume B
Reciprocal space
Edited by U. Shmueli

International Tables for Crystallography (2006). Vol. B, ch. 3.3, pp. 368-370   | 1 | 2 |

Section Windowing and perspective

R. Diamonda*

aMRC Laboratory of Molecular Biology, Hills Road, Cambridge CB2 2QH, England
Correspondence e-mail: Windowing and perspective

| top | pdf |

It is necessary at this point to relate the discussion to the axial system inherent in the graphics device employed. One common system adopts X horizontal and to the right when viewing the screen, Y vertically upwards in the plane of the screen, and Z normal to X and Y with +Z into the screen. This is, unfortunately, a left-handed system in that [({\bf X}\times {\bf Y}) \cdot {\bf Z}] is negative. Since it is usual in crystallographic work to use right-handed axial systems it is necessary to incorporate a matrix of the form [\pmatrix{W &0 &0 &0\cr 0 &W &0 &0\cr 0 &0 &-W &0\cr 0 &0 &0 &W\cr}] either as the left-most factor in the matrix T or as the right-most factor in the windowing transformation U (see Section[link]). The latter choice is to be preferred and is adopted here. The former choice leads to complications if transformations in display space will be required. Display-space coordinates are necessarily referred to this axial system.

Let L, R, T, B, N and F be the left, right, top, bottom, near and far boundaries of the windowed volume [(L\lt R, T\gt B, N\lt F)], S be the Z coordinate of the screen, and C, D and E be the coordinates of the observer's eye position, all ten of these parameters being referred to the origin of display space as origin, which may be anywhere in relation to the hardware. L, R, T and B are to be evaluated in the screen plane. All ten parameters may be referred to their own fourth coordinate, V, meaning that the point (X, Y, Z, W) in display space will be on the left boundary of the picture if [X/W = L/V] when [Z/W = S/V]. V may be freely chosen so that all eleven quantities and all elements of U suit the word length of the machine. These relationships are illustrated in Fig.[link]


Figure | top | pdf |

The relationship between display-space coordinates (X, Y, Z, W) and picture-space coordinates (x, y, z, w) derived from them by the window transformation, U. (a) Display space (in X, Z projection) showing a square object P, Q, R, S for display viewed from the position (C, D, E, V). The bold trapezium is the window (volume) and the bold line is the viewport portion of the screen. The points P, Q, R and S must be plotted at p, q, r and s to give the correct impression of the object. (b) Picture space (in x, z projection). The window is mapped to a rectangle and all sight lines are parallel to the z axis, but the object P, Q, R, S is no longer square. The distribution of p, q, r and s is identical in the two cases. Note that [z/w] values are not linear on [Z/W], and that the origin of picture space arises at the midpoint of the near clipping plane, regardless of the location of the origin of display space. The figure is accurately to scale for coincident viewport positions. The words `Left clipping plane', if part of the scene in display space, would currently be obscured, but would come into view if the eye moved to the right, increasing C, as the left clipping plane would pivot about the point [L/V] in the screen plane.

Since [(X, Y, Z, W) \simeq \left({XV\over W}, {YV\over W}, {ZV\over W}, V\right),] [XV/W] is a display-space coordinate on the same scale as the window parameters. This must be plotted on the screen at an X coordinate (on the scale of the window parameters) which is the weighted mean of [XV/W] and C, the weights being [(S - E)] and [(ZV/W - S)], respectively. This provides perspective because the weighted mean is at the point where the straight line from [(X, Y, Z, W)] to the eye intersects the screen. This then has to be mapped into the L-to-R interval, so that picture-space coordinates [(x, y, z, w)] are given by [\pmatrix{\noalign{\vskip10pt}x\cr\noalign{\vskip15pt} y\cr\noalign{\vskip17pt} z\cr \noalign{\vskip8pt} w\cr} = \pmatrix{\displaystyle{2(S - E) V\over (R - L)} &0 &\displaystyle{(2C - R - L) V\over (R - L)} &\displaystyle{(R + L) E - 2 SC\over (R - L)}\cr \noalign{\vskip3pt} 0 &\displaystyle{2(S - E) V\over (T - B)} &\displaystyle{(2D - T - B) V\over (T - B)} &\displaystyle{(T + B) E - 2 SD\over (T - B)}\cr \noalign{\vskip3pt} 0 &0 &\displaystyle{(F - E) V\over (F - N)} &\displaystyle{- N (F - E)\over (F - N)}\cr \noalign{\vskip3pt} 0 &0 &V &-E\cr} \pmatrix{\noalign{\vskip7pt}X\cr \noalign{\vskip14pt} Y\cr \noalign{\vskip17pt} Z\cr \noalign{\vskip9pt} W\cr}] which provides for [|x/w|] and [|y/w|] to be unity on the picture boundaries, which is usually a requirement of the clipping hardware, and for [0\lt z/w\lt 1], zero being for the near-plane boundary. Even though [z/w] is not linear on [Z/W], straight lines and planes in display space transform to straight lines and planes in picture space, the non-linearity affecting only distances. Thus vector-drawing machines are not disadvantaged by the introduction of perspective.

Note that the dimensionality of [X/W] must equal that of [S/V] and that this may be regarded as length or as a pure number, but that in either case [x/w] is dimensionless, consistent with the stipulation that the picture boundaries be defined by the pure number ±1.

The above matrix is U and is suited to left-handed hardware systems. Note that only the last column of U (the translational part) is sensitive to the location of the origin of display space and that if the eye is on the normal to the picture centre then [C = \;{\textstyle{1\over 2}}\; (R + L)], [D = \;{\textstyle{1\over 2}} (T + B)] and simplifications result. If C, D and E can be continuously monitored then dynamic parallax as well as perspective may be obtained (Diamond et al., 1982[link]).

If data space is referred to right-handed axes, the viewing transformation T involves only proper rotations and the hardware uses a left-handed axial system then elements in the third column of U should be negated, as explained in the opening paragraph.

To provide for orthographic projection, multiply every element of U by [-K/E] and then let [E \rightarrow - \infty], choosing some positive K to suit the word length of the machine [see Section[link] (iii[link])]. The result is [{\bi U}' \simeq \pmatrix{\displaystyle{2KV\over (R - L)} &0 &0 &\displaystyle{-K (R + L)\over (R - L)}\cr \noalign{\vskip3pt} 0 &\displaystyle{2KV\over (T - B)} &0 &\displaystyle{-K (T + B)\over (T - B)}\cr \noalign{\vskip3pt} 0 &0 &\displaystyle{KV\over (F - N)} &\displaystyle{-KN\over (F - N)}\cr \noalign{\vskip3pt} 0 &0 &0 &K\cr},] which is the orthographic window.

It may be convenient in some applications to separate the functions of windowing and the application of perspective, and to write [{\bi U} = {\bi U}'{\bi P},] where U and U′ are as above and P is a perspective transformation given by [{\bi P} = ({\bi U}')^{-1} {\bi U} \simeq \pmatrix{S - E &0 &C &-SC/V\cr \noalign{\vskip3pt} 0 &S - E &D &-SD/V\cr \noalign{\vskip3pt} 0 &0 &F - E + N &-NF/V\cr \noalign{\vskip3pt} 0 &0 &V &-E\cr},] which involves F and N but not R, L, T or B. In this form the action of P may be thought of as compressing distant parts of display space prior to an orthographic projection by U′ into picture space.

Other factorizations of U are possible, for example [{\bi U} = {\bi U}'' {\bi P}'] with [\displaylines{{\bi U}'' \simeq \pmatrix{\displaystyle{2KV\over R - L} &0 &0 &\displaystyle{-K (R + L)\over (R - L)}\cr \noalign{\vskip3pt} 0 &\displaystyle{2KV\over T - B} &0 &\displaystyle{-K (T + B)\over (T - B)}\cr \noalign{\vskip3pt} 0 &0 &\displaystyle{KV(N - E)(F - E)\over E^{2} (F - N)} &\displaystyle{KN (F - E)\over E(F - N)}\cr \noalign{\vskip3pt} 0 &0 &0 &K\cr}\cr \noalign{\vskip3pt} {\bi P}' \simeq \pmatrix{S - E &0 &C &-SC/V\cr \noalign{\vskip3pt} 0 &S - E &D &-SD/V\cr \noalign{\vskip3pt} 0 &0 &-E &0\cr \noalign{\vskip3pt} 0 &0 &V &-E\cr},}] which renders P′ independent of all six boundary planes, but U″ is no longer independent of E. It is not possible to factorize U so that the left factor is a function only of the boundary planes and the right factor a function only of eye and screen positions.

Note that as [E \rightarrow -\infty], [{\bi U}'' \rightarrow {\bi U}'], P and [{\bi P}' \rightarrow -{\bi I}E \simeq {\bi I}].


Diamond, R., Wynn, A., Thomsen, K. & Turner, J. (1982). Three-dimensional perception for one-eyed guys, or, the use of dynamic parallax. In Computational crystallography, edited by D. Sayre, pp. 286–293. Oxford University Press.Google Scholar

to end of page
to top of page