# Compose many Geometric Transformations for 3D Graphics

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}]
}
]
}]


How do I properly compose several sequential geometrical transformations ?

• I figure out the solution as soon as I posted the question and read one of the Related posts. I'm not sure if I should delete this or not. Anyhow I'm looking forward for other better solutions. Commented Oct 15, 2014 at 22:40
• You can use Fold too, but matrix multiplication may be slightly faster: How to render a 3D ellipsoid with Graphics3D?
– Kuba
Commented Oct 15, 2014 at 22:48
• FYI: There is nothing wrong with answering your own question. In fact it is a recommended practice if you have something particularly nice you wish to share e.g. (54784). See: (834) Commented Oct 15, 2014 at 23:48

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}]
}
]
}]


• I did not know that Composition would combine *Transform expressions in this manner so you just taught me something. Thanks and +1. Commented Oct 15, 2014 at 23:51