Vectors To VRML Events - (1)

What is the problem ?

Vectors To VRML Events - (2)

Translating direction to rotation

Vectors To VRML Events - (3)

More detailed
Direction vectors and rotations are something
fundementally different.

The best we can do is calculate a rotation
that 'rotates' a predefined 'defaultDirection'
in such a way that it is the same as our
intended 'direction'.

Vectors To VRML Events - (4)

Why do we ned 'up' ?
The notion of 'up' is needed because
there is one more degree of freedom to
tame, the 'ROLL' (U.S. Mill. term).

Transform { rotation 0 0 1 -1.57 children [ DEF ROLL_TRANS Transform { children [ Transform { translation 0 1 0 children [ Shape { appearance Appearance { material Material { diffuseColor 1 1 1 } } geometry Cone {} } ] } Transform { translation 0 -1.5 0 children [ Shape { appearance Appearance { material Material { diffuseColor 1 1 1 } } geometry Cylinder { height 3 radius 0.5 } } ] } Transform { translation 0.75 -1.5 0 children [ Shape { appearance Appearance { material Material { diffuseColor 1 1 1 } } geometry Box { size 0.5 3 0.5 } } ] } ] } ] } DEF ROLL_TIMER TimeSensor { loop TRUE } DEF ROLL_INTER OrientationInterpolator { key [ 0 0.5 1.0 ] keyValue [ 0 1 0 0, 0 1 0 3.14, 0 1 0 6.28] } ROUTE ROLL_TIMER.fraction_changed TO ROLL_INTER.set_fraction ROUTE ROLL_INTER.value_changed TO ROLL_TRANS.set_rotation

Vectors To VRML Events - (5)

Some Code


  // Rotation from 'def' to 'direction'
  rotA  = new SFRotation(defDirection,direction);
  // Adjust 'up' vector, defUp = yAxis
  up    = rotA.multVec(yAxis);
  // Fix orientation with respect to 'up'
  rotB  = new SFRotation(direction.cross(up),
                         direction.cross(yAxis));
  // Combine both
  orientation = rotA.multiply(rotB);
  

Finally

Let's wrap up...


Any Questions ?