Translation

Translation (parallel displacement), or movement without entailing change in shape or size, is expressed by the following transformational matrix. l, m, and n are respectively related to translation along the X, Y, and Z axes.

        fig120.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

Next, let us parallel displace the "N" 1.2 along the Z axis. The coordinates of P will become (1.0, 2.0, 3.2). Using the message translate:, an instance of Jun3dTransformation is created and the "N" is operated upon. Namely, the message transform: is sent to the "N". P is also translated accordingly.

fig130.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 translate: 0 , 0 , 1.2.
        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

See also:


06 November 1997 / Author: AOKI Atsushi