# Assumptions for RotationMatrix

I'm making C++ program, and in my program I need a rotation matrix around any vector. I wanted to extract RotationMatrix[fi,{x,y,z}] output and put it in my program. Unfortunately Mathematica thinks I operate with imaginary components (x,y,z). Because of that the output that I get is in epic dimensions xD.

I tried to fix this problem with RotationMatrix[fi,{Re[x],Re[y],Re[z]}] but no luck there. Apparently Mathematica doesn't track what type of variable the user defined (real/imaginary).

Is there a way to fix this?

-
How about FullSimplify[RotationMatrix[fi, {x, y, z}], Assumptions -> {x \[Element] Reals, y \[Element] Reals, z \[Element] Reals}]? –  Sjoerd C. de Vries Sep 11 '13 at 21:55
Also take a look at Rodrigues' rotation formula. –  Rahul Sep 11 '13 at 22:23
Sjoerd C. de Vries you are the MAN :) –  urosjarc Sep 11 '13 at 22:26

An even much faster way to accomplish this is:

ComplexExpand[RotationMatrix[fi, {x, y, z}], TargetFunctions -> {Re, Im}] // FullSimplify

-
1+ Appreciated ;) –  urosjarc Sep 12 '13 at 13:53

One solution, as pointed out by Sjoerd, is to tell Mathematica that your variables are not complex.

FullSimplify[RotationMatrix[fi, {x, y, z}], Element[{x, y, z}, Reals]]


This takes very long on my machine. Additionally, please note that it leads in Mathematica version 8 to undesired things, because the result contains piece-wise functions and Conjugate calls. To get the same result, you need to specify that the vector {x,y,z} does not vanish

FullSimplify[RotationMatrix[fi, {x, y, z}],
Element[{x, y, z}, Reals] && ( x!=0 || y!=0 || z!=0 )]


Finally, on my machine it is much faster to first use ComplexExpand and then do the FullSimplify step.

FullSimplify[ComplexExpand[RotationMatrix[fi, {x, y, z}]], Element[{x, y, z}, Reals]]

-
@Kuba Yes, you are right. I wanted to express that {0,0,0} is not allowed and wrote complete crap. Thanks for paying attention. –  halirutan Sep 12 '13 at 10:39
1+ Appreciated ;) –  urosjarc Sep 12 '13 at 13:53