付録 2: サブピクチャの数式
変換
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.
上のブロックは、原文のテキスト組みの数式をそのまま再掲したものである。記号の意味は次のとおり。Mx と My は回転の前に適用される x と y の拡大率 (負の場合は反転を表す)、A は回転角、(cx, cy) は呼び出し側ピクチャにおけるサブピクチャの像の中心、sx と sy は呼び出し側ページ上での像の x 方向と y 方向の半サイズ、(Pcx, Pcy) は呼び出されるサブピクチャの座標系で対応付けられる部分の中心 (既定値は (0, 0))、Psx と Psy はその部分の x と y の半サイズ (既定値はそれぞれ +1/2) である。
入れ子レベルでの変換
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 /)
/_ _/
したがって、完全サブピクチャの呼び出しが入れ子になっている場合、どのレベルのデータも一度だけ変換すればよい。すなわち、各入れ子レベルの単一ステップの変換を合成した変換によって変換する。完全サブピクチャが呼び出されるたびに (現在の変換をプッシュダウンした後)、現在の「総合成」アフィン変換を、この特定のサブピクチャ呼び出しのアフィン変換と合成することにより、新しい「総合成」アフィン変換を計算すべきである。
入れ子レベルでの部分
回転が含まれない、あるいは pi/2 の倍数の回転のみが含まれる場合であれば、複数レベルの部分の実装は容易である。次の 2 段落の議論では、pi/2 の整数倍以外の回転は含まれないものと仮定する。
「総合成」アフィン変換を管理できるのと同様に、部分の総合成も管理できる。各レベルで、次のように進めることができる。現在の総合部分のコピーを保存し、(サブピクチャ呼び出しで指定された) 単一レベルのアフィン変換の逆変換を使って、呼び出されるページ上のどの矩形が (呼び出し側ページ上の) 現在の総合部分に対応するかを決定する。
この矩形と、サブピクチャ呼び出しで指定された (または既定の) 矩形の間には、さまざまな関係が成り立ちうる。互いに素であるかもしれない (その場合、このサブピクチャは呼び出す必要がまったくない)。等しいかもしれない (容易な場合)。一方が他方を含むか、部分的に重なるかもしれない。交差部分があれば、それは矩形になり、この矩形が新しい総合成の部分となる。
pi/2 の倍数以外の回転の問題は、矩形の逆像がもはや標準の向き (垂直および水平の辺) にないことである。このため、サブピクチャ呼び出しで指定された部分との交差部分は (空でなければ) 3、4、5、6、7、8 辺のいずれかになりうる。より深いレベルが回転も含む場合は、さらに悪くなりうる。このような状況を扱うことに (人によっては) 概念上の困難はないかもしれないが、単純な水平・垂直の辺の場合よりも、はるかに多くの計算が必要になる。
このプロトコルは、pi/2 の整数倍以外の回転が部分に関わる場合については、何も推奨しない。入れ子の部分は、より単純な場合には上述のとおりに扱うことを提案する。
[This RFC was put into machine readable form for entry]
[into the online RFC archives by Helene Morin, Via Genie, 12/1999]