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

3. rotation(回転)


rotation は、物体の回転を記述するために用います。
rotation と書いて、その後に { } をつけて、
{ } の中に回転軸方向(x y z)および回転の大きさを書きます。


以下、x軸に沿って回転した円柱を左側に、
z軸に沿って回転した円柱を右側に表示した例です。

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


#VRML V2.0 utf8

Transform {
  rotation 1.0 0.0 0.0 0.8
  translation -2.0 0.0 0.0 
  children [
    Shape {
      geometry Cylinder {
        height 2.0
        radius 1.5
      }
    }
  ]
}

Transform {
  rotation 0.0 0.0 1.0 1.1
  translation 2.0 0.0 0.0 
  children [
    Shape {
     geometry Cylinder {
      height 2.0
      radius 1.5
     }
    }
  ]
}

ここで「回転の大きさ」は、180度を3.14として、
90度を1.57とした数字で表します。
ちょっと難しいですが、いろいろ試してみてください。

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

続いて拡大 ...


目次に戻る