Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 9 down vote accepted

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.

share|improve this answer
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? – Michael E2 Oct 9 '13 at 10:22
This is very insightful! Makes a lot of sense now. Thank you! – Brady Hunt Oct 9 '13 at 12:26
@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. – bill s Oct 9 '13 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.)

share|improve this answer
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. – Brady Hunt Oct 9 '13 at 12:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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