13

I'm struggling to understand what would be a good way to compose several geometrical transformations to create a single TransformationFunction to be applied to a GeometricTransformation. One way could be to obtain a set of TransformationMatrix and multiply.

On this answer what I would have liked to achieve is to perform two rotations in different axis and then a translation in order to create a realistic trajectory of a falling cube, knowing height vs time and also the angles of elevation and azimuth vs time.

If I give a list of transformation functions these are applied to different copies of the original object instead of the same in sequence

Graphics3D[{
  Opacity[1]
  , Red
  , Arrow[{{0, 0, 0}, {1, 0, 0}}]
  , Green
  , Arrow[{{0, 0, 0}, {0, 1, 0}}]
  , Blue
  , Arrow[{{0, 0, 0}, {0, 0, 1}}]
  , Opacity[0.2]
  , GeometricTransformation[Cuboid[-{1, 1, 1}/4, {1, 1, 1}/4],
   {
    RotationTransform[Pi/4, {0, 0, 1}]
    , TranslationTransform[{1, 1, 1}]
    }
   ]
  }]

Mathematica graphics

How do I properly compose several sequential geometrical transformations ?

rhermans
  • 36,518
  • 4
  • 57
  • 149

1 Answers1

15

Using Composition I can apply RotationTransform, TranslationTransform , ShearingTransform one after the other.

Graphics3D[{
  Opacity[1]
  , Red
  , Arrow[{{0, 0, 0}, {1, 0, 0}}]
  , Green
  , Arrow[{{0, 0, 0}, {0, 1, 0}}]
  , Blue
  , Arrow[{{0, 0, 0}, {0, 0, 1}}]
  , Opacity[0.2]
  , GeometricTransformation[Cuboid[-{1, 1, 1}/4, {1, 1, 1}/4],
   Composition @@ {
     RotationTransform[Pi/4, {0, 0, 1}]
     , TranslationTransform[{1, 1, 1}]
     , ShearingTransform[Pi/8, {1, 0, 0}, {0, 0, 1}]
     }
   ]
  }]

Mathematica graphics

rhermans
  • 36,518
  • 4
  • 57
  • 149
  • 3
    I did not know that Composition would combine *Transform expressions in this manner so you just taught me something. Thanks and +1. – Mr.Wizard Oct 15 '14 at 23:51