形と大きさを変化させない平行移動は,次の変換行列で表わされます。l,m,nが,X軸,Y軸,Z軸の平行移動に関わります。
Nのような文字を,左下奥を原点に合わせて描き,右上前の点をPとします。この点Pの座標(1.0, 2.0, 2.0)は文字Nの大きさになっています。そして,X軸,Y軸,Z軸は,それぞれ,赤,緑,青で表現されています。
| 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をZ軸に沿って1.2だけ平行移動してみましょう。点Pの座標は(1.0, 2.0, 3.2)になります。translate:のメッセージを使って,Jun3dTransformationのインスタンスを作成し,文字Nに作用させます。すなわち,文字Nにtransform:のメッセージを送ります。同様に点Pも平行移動しておきます。
| 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