korppu73
korppu73

Reputation: 339

Order of transformations in X3d

I have the following 2 transformations applied to a cylinder in X3d:

  <Transform   rotation="0 0 1 -0.785">
    <Transform  translation="0 2 0">      
      <Shape><Cylinder height="4" radius="0.1" />
      <Appearance><Material diffuseColor="1 0 0" /></Appearance>
      </Shape>
    </Transform>
  </Transform>

According to the X3d specifications the order in which nested transformations are applied to an object is, first the most nested transformation, in my example, the translation and secondly the outer transformation,ie in my example, the rotation.

Therefore, I do not understand that this is the result of the X3d code above:

enter image description here

As I understand, it should be this:

enter image description here

because first a translation is applied to the cylinder moving its mid-point from (0,0,0) to (0,2,0),and then a rotation is applied. The center of rotation should be (0, 2,0), not (0,0,0) as the result of the first image would suggest.

Thank you for any explanation to why I understand it backwards.

Upvotes: 0

Views: 133

Answers (2)

user3059287
user3059287

Reputation: 56

Centered at the origin is the cylinder with a height of 4. Making a translation of 2 in the yy' axis, means that the cilinder goes up 2 units, so its basis becomes at the origin. Then, the rotation of -45 degrees around the z' axis causes a rotation, and as this object has a point at the origin, that point still keeps its position at the origin, while the cylinder is rotated (-45 degrees).

This happens because all the rotations are performed around the pivot point (0,0,0) and not around the center point of the shapes.

Upvotes: 0

Vincent Marchetti
Vincent Marchetti

Reputation: 4908

The misunderstanding is your incorrect assertion that "the center of rotation should be 2.0...". The outer transform does takes no account of the fact that the inner transform has in a sense shifted the origin. Put another way, the transforms in X3D are active, they shift the shapes inside, not the coordinate system. The inner transform moves the cylinder "up" along the y axis, leaving the coordinate system unchanged. The outer transform then applies a rotation of -pi/4 about the unchanged z axis, which passes through the origin (0,0,0)

Upvotes: 0

Related Questions