Passa al contenuto principale

Appendice 2: Formule matematiche per le sottoimmagini

Trasformazioni​

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.

Il blocco precedente riproduce senza modifiche le formule composte in testo semplice dell'originale. Significato dei simboli: Mx e My sono gli ingrandimenti in x e y da applicare prima di qualsiasi rotazione (possono essere negativi, a indicare una riflessione); A è l'angolo di rotazione; (cx, cy) è il centro dell'immagine della sottoimmagine nell'immagine chiamante; sx e sy sono le semidimensioni dell'immagine sulla pagina chiamante nelle direzioni x e y; (Pcx, Pcy) è il centro della porzione da mappare nel sistema di coordinate della sottoimmagine chiamata (valore predefinito (0, 0)); Psx e Psy sono le semidimensioni di tale porzione in x e y (valore predefinito +1/2 ciascuna).

Trasformazioni con livelli annidati​

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 /)
/_ _/

Pertanto, in presenza di chiamate annidate di sottoimmagini complete, i dati a qualunque livello devono essere trasformati una sola volta, cioè dalla trasformazione che è la combinazione delle trasformazioni a passo singolo di ciascun livello di annidamento. Una nuova trasformazione affine di "combinazione complessiva" dovrebbe essere calcolata ogni volta che viene chiamata una sottoimmagine completa (dopo aver salvato nello stack la trasformazione corrente), combinando la combinazione complessiva corrente con la trasformazione affine di questa particolare chiamata di sottoimmagine.

Porzioni con livelli annidati​

Finché non sono coinvolte rotazioni, o anche solo rotazioni di multipli di pi/2, più livelli di porzioni sono facili da implementare. Nella discussione dei prossimi due paragrafi supponiamo che non siano coinvolte rotazioni diverse da multipli interi di pi/2.

Come si può tenere traccia di una trasformazione affine di "combinazione complessiva", così si può tenere una combinazione complessiva di porzioni. A ciascun livello, si può procedere come segue: salvare una copia della porzione complessiva corrente e usare l'inversa della trasformazione affine a livello singolo (specificata nella chiamata di sottoimmagine) per determinare quale rettangolo della pagina chiamata corrisponde alla porzione complessiva corrente (sulla pagina chiamante).

Tra questo rettangolo e il rettangolo specificato (o predefinito) nella chiamata di sottoimmagine possono esistere varie relazioni. Possono essere disgiunti (nel qual caso questa sottoimmagine non deve essere chiamata affatto); possono essere uguali (un caso facile); uno può contenere l'altro oppure possono sovrapporsi parzialmente. Se c'è un'intersezione, essa sarà un rettangolo, e questo rettangolo diventa la nuova porzione di combinazione complessiva.

Il problema delle rotazioni diverse dai multipli di pi/2 è che l'immagine inversa del rettangolo non è più nell'orientamento standard (lati verticali e orizzontali). Ciò significa che la sua intersezione con la porzione specificata nella chiamata di sottoimmagine può avere 3, 4, 5, 6, 7 o 8 lati (se non è vuota). I livelli più profondi possono andare anche peggio se coinvolgono anch'essi rotazioni. Sebbene possa non esserci (per alcuni) alcuna difficoltà concettuale nel lavorare con una situazione del genere, è coinvolto un calcolo significativamente maggiore rispetto al semplice caso di lati orizzontali e verticali.

Questo protocollo non avanza alcuna raccomandazione nel caso in cui rotazioni diverse da multipli interi di pi/2 siano coinvolte con le porzioni. Suggerisce però che le porzioni annidate siano gestite come descritto sopra nel caso più semplice.

[This RFC was put into machine readable form for entry]
[into the online RFC archives by Helene Morin, Via Genie, 12/1999]