Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
3  
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 :) –  Physicist Sep 11 '13 at 22:26

2 Answers 2

An even much faster way to accomplish this is:

ComplexExpand[RotationMatrix[fi, {x, y, z}], TargetFunctions -> {Re, Im}] // FullSimplify
share|improve this answer
    
1+ Appreciated ;) –  Physicist 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]]
share|improve this answer
    
@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 ;) –  Physicist Sep 12 '13 at 13:53

Your Answer

 
discard

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.