The code that I have written has an unintended consequence that I'm not sure how to get around. I want 3 rotation transforms to be applied simultaneously to 1 graphics object. Instead, I get 3 separate separate copies of the graphics object, one per transformation.

The documentation does state that this will be the outcome of using multiple transformations on a graphics object.

GeometricTransformation[g, {t1, t2, ...}]
represents multiple copies of g transformed by a collection of transformations.

My question is: how is it possible to achieve the the outcome that I described instead of getting multiple copies?

Here is the code I am executing:

      {RotationTransform[a Pi, {1, 0, 0}], 
       RotationTransform[b Pi, {0, 1, 0}], 
       RotationTransform[c Pi, {0, 0, 1}]}]}], 
  {{a, 0}, -1, 1}, 
  {{b, 0}, -1, 1}, 
  {{c, 0}, -1, 1}, 
  SaveDefinitions -> True]

If anyone could show me a way to accomplish this, I'd appreciate it.


2 Answers 2


RotationTransform[a Pi, {1, 0, 0}] is nothing more than a matrix, so you can compose/combine such functions using matrix multiplication. For example:

      RotationTransform[.5 Pi, {1, 0, 0}].RotationTransform[0.2 Pi, {0, 1, 0}].RotationTransform[0.1 Pi, {0, 1, 0}]]}]

enter image description here

In the above code the dot . stands for matrix multiplication, which applies the various transformations in sequence.

  • $\begingroup$ Interesting. Strictly speaking, a transform is a TransformationFunction of a matrix, and I had always used TransformationMatrix to get the matrix to work with. The manual does not seem to include your usage of Dot. Is it documented or did you just happen on it some way? $\endgroup$
    – Michael E2
    Oct 9, 2013 at 10:22
  • $\begingroup$ This is very insightful! Makes a lot of sense now. Thank you! $\endgroup$
    – Brady Hunt
    Oct 9, 2013 at 12:26
  • $\begingroup$ @Michael E2 You are correct in that these are TransformationFunctions (and not, strictly speaking, the matrices themselves). For example, Dot does not work in all cases: you cannot take the product of a RotationMatrix and a vector. I don't recall when I first saw this. $\endgroup$
    – bill s
    Oct 9, 2013 at 13:18

Use Composition:

     RotationTransform[a Pi, {1, 0, 0}], 
     RotationTransform[b Pi, {0, 1, 0}], 
     RotationTransform[c Pi, {0, 1, 0}]]]}],
 {{a, 0}, -1, 1}, {{b, 0}, -1, 1}, {{c, 0}, -1, 1}, 
 SaveDefinitions -> True]

Mathematica graphics

(I'm not sure which order you want, and whether the c rotation is meant to be about the y-axis as in the OP's code.)

  • $\begingroup$ This is perfect! Thanks! And yeah, the c rotation was meant to be about the z-axis {0,0,1}, that was just a mistake. Of course, rotation about the z-axis for a cylinder does absolutely nothing because of symmetry, but I will use this transformation for a number of different objects. Thanks again. $\endgroup$
    – Brady Hunt
    Oct 9, 2013 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.