Scaling (magnifying and shrinking)

Enlarging or shrinking (rescaling) a solid centered on the point of origin is expressed by the following transformational matrix. a, e, and i are connected with the X, Y, and Z axes in the scaling operation.

        fig070.gif

As an example, take a three-dimensional "N" shape, matching the farthest point on its bottom left edge with the coordinate system's point of origin and defining the nearest point on the upper right edge as point P. The coordinates of P, i.e. (1.0, 2.0, 2.0) will represent the size of the character "N". The X, Y, and Z axes will be shown in the respective colors of red, green, and blue.

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

Let us enlarge "N" 1.5-fold. The coordinates of P become (1.5, 3.0, 3.0). Using the message scale:, an instance of Jun3dTransformation is created and the "N" is operated upon. Namely, the message transform: is sent to the "N". P is also moved accordingly.

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

Next, shrink the original "N" to half (0.5-fold) its size. The coordinates of P will become (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

Now reverse the signs of the X and Y coordinate values, while keeping the scaling factor at 1 (no change). This will invert the "N" with respect to the X and Y axes, and the coordinates of P become (-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

Refer to the following for a summarization of the above details.

a > 1 :

Enlarge along the X axis

1 > a > 0 :

Shrink along the X axis

0 > a :

Invert along the X axis (invert with respect to the YZ plane)

e > 1 :

Enlarge along the Y axis

1 > e > 0 :

Shrink along the Y axis

0 > e :

Invert along the X axis (invert with respect to the XZ plane)

i > 1 :

Enlarge along the Z axis

1 > i > 0 :

Shrink along the Z axis

0 > i :

Invert along the X axis (invert with respect to the XY plane)

See also:


06 November 1997 / Author: AOKI Atsushi