Annexe 2 : Formules mathématiques pour les sous-images
Transformations
In this appendix positions in a logical coordinate system will be
represented by a row vector with two elements, as in /_ x y_/. Vectors
and matrices will be delimited by these funny brackets: /_ _/. Various
symbols will be used to represent parameters in a full subpicture call
relating to a transformation from one coordinate system to another;
these are defined below:
Mx and My : magnifications in x and y to be applied before any
rotation.
They may be negative indicating reflection.
A: an angle of rotation in the range 0 to just less than 2pi.
/_ |cx |cy_/ : the center (in the calling picture) of the image of the
subpicture.
|sx |sy : the half-sizes, in the x and y directions, of the
image on the calling page in terms of the calling page's
coordinate system.
They may be negative to indicate reflection.
/_ x y_/ : a position on the called page.
/_ |x |y_/ : the position on the calling page corresponding to /_x y_/.
/_ Pcx Pcy_/ : The center of the portion of the called subpicture's
coordinate system which is to be mapped to the calling
page.
This defaults to /_ 0 0_/ if not specified.
Psx and Psy : The half-sizes in x and y of the portion of the
subpicture to be mapped. These both default to +1/2
in not specified.
(If a uniform magnification is specified, set Mx and My equal to it and
proceed below as if they were specified.)
If magnifications are specified, the following holds:
/_ |x |y_/ = (/_ x y_/ - /_ Pcx Pcy_>) * / Mx/Psx 0 / *
/_ 0 My/Psy_/
/ cos 0 sin 0 / * / 1/2 0 / + /_ |cx |cy_/
/_ -sin0 cos0_/ /_ 0 1/2_/
or in other words,
1)
/_|x |y_/ = /_ x-Pcx y-Pcy_/ * / Mx cosA/2Psx Mx sinA/2Psx /
/_ -My sinA/2Psy My cosA/2Psy_/
+/_ |cx |cy_/
(The factor of 1/2 is necessary because, for instance, (x-Pcx)/Psx
ranges from -1 to +1 for x values within the portion (i.e., such that
|x-Pcx| <|Psx| ) whereas the image, in the calling subpicture's
coordinate system, should only range from -1/2 to +1/2.)
If the image size is specified instead of the magnification, we have the
following:
/_ |x |y_/ = (/_ x y_/ - /_Pcx Pcy_/) * / 1/Psx 0 / *
/_ 0 1/Psy _/
/ cosA sinA / * / |sx 0 / + /_ |cx |cy_/
/_ -sinA cosA _/ /_ 0 |sy _/
or, in other words,
2)
/_|x |y_/ = /_x-Pcx y-Pcy_/ * /|sx cosA/Psx |sy sinA/Psx /
/_-|sx sinA/Psy |sy cosA/Psy_/
+ /_|cx |cy_/
Expanding the parenthesized quantities in equations 1) and 2), we
have:
3a) /_|x |y_/ = /_x y_/ * /Mx cosA/2Psx Mx sinA/2Psx /
/_-My sinA/2Psy My cosA/2Psy_/
+ /_|cx-PcxMxcosA/2Psx+PcyMysinA/2Psy
|cy-PcxMxsinA/2Psx-PcyMycosA/2Psy _/
and
3b) /_|x |y_/ = /_x y_/ * /|sx cosA/Psx |sy sinA/Psx /
/_-|sx sinA/Psy |sy cosA/Psy_/
+ /_|cx-Pcx|sxcosA/Psx+Pcy|sxsinA/Psy
|cy-Pcy|sysinA/Psx-Pcy|sycosA/Psy_/
Various interesting substitutions can be made in 3a) and 3b).
For example, if A=0 (no rotation), then we have:
4a) /_|x |y_/ = /_x y_/ * /Mx/2Psx 0 / + /_|cx-PcxMx/2Psx
|cy-PcyMy/2Psy_/
/_ 0 My/2Psy_/
4b) /_|x |y_/ = /_x y_/ * /|sx/Psx 0 / + /_|cx-Pcx|sx/Psx
|cy-Pcy|sy/Psy_/
/_ 0 |sy/Psy_/
Another example is if no portioning is done (Pcx=Pcy=0, Psx=Psy=1/2):
5a) /_|x |y_/ = /_ x y_/ * /Mx cosA Mx sinA / + /_|cx |cy_/
/_-My sinA My sinA_/
5b) /_|x |y_/ = /_ x y_/ * /2|sx cosA 2|sy sinA / + /_|cx |cy_/
/_-2|sx sinA 2|sx cosA_/
If in addition, 0=0, we have:
6a) /_|x |y_/ = /_ xMx+|cx yMy+|cy_/
6b) /_|x |y_/ = /_ x*2|sx+|cx y*2|sy+|cy_/
Of course, in all cases, the transformation from /_x y_/ to /_|x |y_/
can be written in the form:
/_|x |y_/ = /_x y_/ * / 2 by 2 / + /_ translation _/
/_ matrix _/
In general, a transformation combining a linear transformation and a
translation is called an affine transformation.
Le bloc ci-dessus reproduit tel quel les formules composées en texte brut de l'original. Signification des symboles : Mx et My sont les grossissements en x et en y à appliquer avant toute rotation (ils peuvent être négatifs, ce qui indique une réflexion) ; A est l'angle de rotation ; (cx, cy) est le centre de l'image de la sous-image dans l'image appelante ; sx et sy sont les demi-tailles de l'image sur la page appelante dans les directions x et y ; (Pcx, Pcy) est le centre de la portion à reproduire dans le système de coordonnées de la sous-image appelée (par défaut (0, 0)) ; Psx et Psy sont les demi-tailles de cette portion en x et en y (par défaut +1/2 chacune).
Transformations avec niveaux imbriqués
The combination of two affine transformations is again an affine
transformation. Indeed, if
/_|x |y_/ = /_x y_/ * / Mat1 / + /_ Tran1 _/
/_ _/
and
/_|x_ |y__/ = /_|x |y_/ * ( / Mat1 / * / Mat2 /)
/_ _/ /_ _/
+ (/_ Tran2 _/ + /_ Tran1 _/ * / Mat2 /)
/_ _/
Ainsi, en présence d'appels imbriqués de sous-images complètes, les données à un niveau quelconque n'ont à être transformées qu'une seule fois, à savoir par la transformation qui est la combinaison des transformations élémentaires de chaque niveau d'imbrication. Une nouvelle transformation affine de « combinaison globale » devrait être calculée chaque fois qu'une sous-image complète est appelée (après avoir empilé la transformation courante), en combinant la combinaison globale courante avec la transformation affine de cet appel particulier de sous-image.
Portions avec niveaux imbriqués
Tant qu'aucune rotation n'intervient, ou même seulement des rotations multiples de pi/2, plusieurs niveaux de portions sont faciles à mettre en œuvre. Dans la discussion des deux paragraphes suivants, supposons qu'aucune rotation autre que des multiples entiers de pi/2 n'intervient.
De même que l'on peut tenir à jour une transformation affine de « combinaison globale », on peut tenir à jour une combinaison globale de portions. À chaque niveau, on peut procéder ainsi : sauvegarder une copie de la portion globale courante, et utiliser l'inverse de la transformation affine à un seul niveau (spécifiée dans l'appel de sous-image) pour déterminer quel rectangle de la page appelée correspond à la portion globale courante (sur la page appelante).
Diverses relations peuvent exister entre ce rectangle et le rectangle spécifié (ou pris par défaut) dans l'appel de sous-image. Ils peuvent être disjoints (auquel cas cette sous-image n'a pas besoin d'être appelée du tout) ; ils peuvent être égaux (un cas facile) ; l'un peut contenir l'autre, ou ils peuvent se chevaucher partiellement. S'il y a une intersection, ce sera un rectangle, et ce rectangle devient la nouvelle portion de combinaison globale.
Le problème des rotations autres que les multiples de pi/2 est que l'image réciproque du rectangle n'est plus dans l'orientation standard (côtés verticaux et horizontaux). Cela signifie que son intersection avec la portion spécifiée dans l'appel de sous-image peut avoir 3, 4, 5, 6, 7 ou 8 côtés (si elle est non vide). Les niveaux plus profonds peuvent être encore pires s'ils impliquent aussi des rotations. Si travailler dans une telle situation ne pose peut-être (pour certains) aucune difficulté conceptuelle, cela implique nettement plus de calculs que dans le cas simple des côtés horizontaux et verticaux.
Ce protocole ne fait aucune recommandation dans le cas où des rotations autres que des multiples entiers de pi/2 interviennent avec des portions. Il suggère toutefois que les portions imbriquées soient traitées comme décrit ci-dessus dans le cas plus simple.
[This RFC was put into machine readable form for entry]
[into the online RFC archives by Helene Morin, Via Genie, 12/1999]