Advertisement
boos

mathematica notebook

Sep 19th, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. sposition = {ex, ey, ez} (* starting position *)
  2. rposition = {rx, ry, rz} (* real end position *)
  3.  
  4. RX[a_] = RotationMatrix[ a, {1, 0, 0}] (* Rotation Matrix on X axis of a degree *)
  5. RY[b_] = RotationMatrix[ b, {0, 1, 0}] (* Rotation Matrix on Y axis of a degree *)
  6. RZ[c_] = RotationMatrix[ c, {0, 0, 1}] (* Rotation Matrix on Z axis of a degree *)
  7.  
  8. ReX[ea_] = RotationMatrix[ ea, {1, 0, 0}] (* Rotation Matrix Error on X axis of ea degree *)
  9. ReY[eb_] = RotationMatrix[ eb, {0, 1, 0}] (* Rotation Matrix Error on Y axis of ea degree *)
  10. ReZ[ec_] = RotationMatrix[ ec, {0, 0, 1}] (* Rotation Matrix Error on Z axis of ea degree *)
  11.  
  12. TX[x_, ta_] = Translate[x, {ta, 0, 0}] (* Translation on axis X *)
  13. TY[y_, tb_] = Translate[y, {0, tb, 0}] (* Translation on axis Y *)
  14. TZ[z_, tc_] = Translate[z, {0, 0, tc}] (* Translation on axis Z *)
  15.  
  16. TeX[x_, tea_] = Translate[x, {tea, 0, 0}] (* Translation error on X axis *)
  17. TeY[y_, teb_] = Translate[y, {0, teb, 0}] (* Translation error on Y axis *)
  18. TeZ[z_, tec_] = Translate[z, {0, 0, tec}] (* Translation error on Z axis *)
  19.  
  20. (* RotoTranslation function for every axis with error both in the rotation and the traslation *)
  21.  
  22. RotoTranslationX[position_, a_, ea_, ta_, tea_] = TeX[TX[ReX * RX[a]* position, ta], tea]
  23. RotoTranslationY[position_, b_, eb_, tb_, teb_] = TeY[TY[ReY * RY[b]* position, tb], teb]
  24. RotoTranslationZ[position_, c_, ec_, tc_, tec_] = TeZ[TZ[ReZ * RZ[c]* position, tc], tec]
  25.  
  26. (* One camera RotoTreaslation *)
  27. Camera[position_, a_, ea_, ta_, tea_, b_, eb_, tb_, teb_, c_, ec_, tc_, tec_] = RotoTranslationZ[ RotoTranslationY[RotoTranslationX[position, a, ea, ta, tea], b, eb, tb, teb], c, ec, tc, tec]
  28.  
  29. (* Two camera RotoTraslation .. get the position of the object from the previous camera and compute the position from the actual camera *)
  30. Camera[ Camera[position_, a_, ea_, ta_, tea_, b_, eb_, tb_, teb_, c_, ec_, tc_, tec_], a_, ea_, ta_, tea_, b_, eb_, tb_, teb_, c_, ec_, tc_, tec_ ] // MatrixForm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement