拡大・縮小 (scaling)

 原点を中心にした拡大および縮小は,次の変換行列で表わされます。a,e,iが,X軸,Y軸,Z軸の拡大および縮小に関わります。

        fig070.gif

 Nのような文字を,左下奥を原点に合わせて描き,右上前の点をPとします。この点Pの座標(1.0, 2.0, 2.0)は文字Nの大きさになっています。そして,X軸,Y軸,Z軸は,それぞれ,赤,緑,青で表現されています。

fig080.gif
        | characterN pointP xyzAxes compoundObject |
        characterN := JunOpenGL3dObject characterN.
        characterN paint: ColorValue magenta.
        characterN := characterN translatedBy: characterN boundingBox corner.
        pointP := JunOpenGL3dObject cube.
        pointP := pointP scaledBy: 0.1.
        pointP := pointP translatedBy: characterN boundingBox corner.
        xyzAxes := JunOpenGL3dObject axes.
        xyzAxes := xyzAxes scaledBy: 3.5.
        compoundObject := JunOpenGL3dCompoundObject new.
        compoundObject add: characterN.
        compoundObject add: xyzAxes.
        compoundObject add: pointP.
        compoundObject show.
        Transcript cr; show: pointP boundingBox center printString

 この文字Nを1.5倍の大きさに拡大してみましょう。点Pの座標は(1.5, 3.0, 3.0)になります。scale:のメッセージを使って,Jun3dTransformationのインスタンスを作成し,文字Nに作用させます。すなわち,文字Nにtransform:のメッセージを送ります。同様に点Pも拡大しておきます。

fig090.gif
        | characterN pointP aTransformation xyzAxes compoundObject |
        characterN := JunOpenGL3dObject characterN.
        characterN paint: ColorValue magenta.
        characterN := characterN translatedBy: characterN boundingBox corner.
        pointP := JunOpenGL3dObject cube.
        pointP := pointP scaledBy: 0.1.
        pointP := pointP translatedBy: characterN boundingBox corner.
        aTransformation := Jun3dTransformation scale: 1.5 , 1.5 , 1.5.
        characterN := characterN transform: aTransformation.
        pointP := pointP transform: aTransformation.
        xyzAxes := JunOpenGL3dObject axes.
        xyzAxes := xyzAxes scaledBy: 3.5.
        compoundObject := JunOpenGL3dCompoundObject new.
        compoundObject add: characterN.
        compoundObject add: xyzAxes.
        compoundObject add: pointP.
        compoundObject show.
        Transcript cr; show: pointP boundingBox center printString

 次に,元の文字Nを半分(0.5倍)の大きさに縮小してみましょう。点Pの座標は(0.5, 1.0, 1.0)になります。

fig100.gif
        | characterN pointP aTransformation xyzAxes compoundObject |
        characterN := JunOpenGL3dObject characterN.
        characterN paint: ColorValue magenta.
        characterN := characterN translatedBy: characterN boundingBox corner.
        pointP := JunOpenGL3dObject cube.
        pointP := pointP scaledBy: 0.1.
        pointP := pointP translatedBy: characterN boundingBox corner.
        aTransformation := Jun3dTransformation scale: 0.5 , 0.5 , 0.5.
        characterN := characterN transform: aTransformation.
        pointP := pointP transform: aTransformation.
        xyzAxes := JunOpenGL3dObject axes.
        xyzAxes := xyzAxes scaledBy: 3.5.
        compoundObject := JunOpenGL3dCompoundObject new.
        compoundObject add: characterN.
        compoundObject add: xyzAxes.
        compoundObject add: pointP.
        compoundObject show.
        Transcript cr; show: pointP boundingBox center printString

 倍率を等倍にして,X軸とY軸の符号のみを逆転してみましょう。すると,文字NがX軸とY軸にそれぞれ裏返り,点Pの座標は(-1.0, -2.0, 2.0)になります。

fig110.gif
        | characterN pointP aTransformation xyzAxes compoundObject |
        characterN := JunOpenGL3dObject characterN.
        characterN paint: ColorValue magenta.
        characterN := characterN translatedBy: characterN boundingBox corner.
        pointP := JunOpenGL3dObject cube.
        pointP := pointP scaledBy: 0.1.
        pointP := pointP translatedBy: characterN boundingBox corner.
        aTransformation := Jun3dTransformation scale: -1 , -1 , 1.
        characterN := characterN transform: aTransformation.
        pointP := pointP transform: aTransformation.
        xyzAxes := JunOpenGL3dObject axes.
        xyzAxes := xyzAxes scaledBy: 3.5.
        compoundObject := JunOpenGL3dCompoundObject new.
        compoundObject add: characterN.
        compoundObject add: xyzAxes.
        compoundObject add: pointP.
        compoundObject show.
        Transcript cr; show: pointP boundingBox center printString

 以上をまとめると,次のようになります。

            a > 1 : X軸において拡大
        1 > a > 0 : X軸において縮小
        0 > a     : X軸において反転(YZ平面に対して反転)
            e > 1 : Y軸において拡大
        1 > e > 0 : Y軸において縮小
        0 > e     : Y軸において反転(XZ平面に対して反転)
            i > 1 : Z軸において拡大
        1 > i > 0 : Z軸において縮小
        0 > i     : Z軸において反転(XY平面に対して反転)

参照 (see also)


1997年11月06日 文責: 青木 淳