物体の幾何変換(移動、回転など)

2. translation(平行移動)


translation は、物体の平行移動を記述するために用います。
translation と書いて、その後に { } をつけて、
{ } の中に平行移動方向(x y z)を書きます。


以下、左上に平行移動した円すいと、
右下に平行移動した球の例です。

translation 以下の値の違いに着目してください。
また、円すい(Cone)と球(Sphere)が、children の後の
[ ] の中に書かれていることに着目してください。

#VRML V2.0 utf8

Transform {
  translation -2.0 2.0 0.0 
  children [
    Shape {
      geometry Cone {
        height 3.0
        bottomRadius 2.0
      }
    }
  ]
}

Transform {
  translation 3.0 -1.0 0.0 
  children [
    Shape {
     geometry Sphere {
      radius 2.0
     }
    }
  ]
}

上の VRML を実際に表示してみましょう。

続いて回転 ...


目次に戻る