Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int i;
  9. cout << "ilosc przemieszczen=";
  10. cin >> i;
  11. cout << std::endl;
  12. double tab[i][4];
  13. for(int x=0;x<i;++x)
  14. {
  15. cout << "przemieszczenei nr " << x+1 << std::endl;
  16. cout << "(DH)a_=";
  17. cin >> tab[x][0];
  18. cout << std::endl;
  19. cout << "(DH)d_=";
  20. cin >> tab[x][1];
  21. cout << std::endl;
  22. cout << "(DH)alfa_=";
  23. cin >> tab[x][2];
  24. cout << std::endl;
  25. cout << "(DH)theta_=";
  26. cin >> tab[x][3];
  27. cout << std::endl;
  28. }
  29. for (int x=0; x<i; ++x)
  30. {
  31. double cos_theta = cos(tab[x][3]);
  32. double sin_theta = sin(tab[x][3]);
  33. double cos_alpha = cos(tab[x][2]);
  34. double sin_alpha = sin(tab[x][2]);
  35.  
  36. double fi = atan2(cos_theta*sin_alpha, cos_alpha);
  37. double theta = atan2(-1*sin_theta*sin_alpha, sqrt(1 - cos_theta*sin_alpha*cos_theta*sin_alpha));
  38. double psi = atan2(sin_theta*cos_alpha, cos_theta);
  39.  
  40. cout <<"**********************"<<endl << "(RPY) roll: " << psi << " pitch: " << theta << " yaw: " << fi << endl;
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement