Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include<list>
  4.  
  5. using namespace std;
  6.  
  7. class Punto {
  8.  
  9. string id;
  10. double vx, vy, vz, m, px, py, pz;
  11. list<Punto> punti;
  12.  
  13. public:
  14.  
  15. Punto(string id = "~", double vx = 0, double vy = 0, double vz = 0, double m = 0)
  16.  
  17. {
  18. (*this).id = id;
  19. this->vx = vx;
  20. this->vy = vy;
  21. this->vz = vz;
  22. this->m = m;
  23. this->px = px;
  24. this->py = py;
  25. this->pz = pz;
  26. }
  27.  
  28. void add(string id, double vx, double vy, double vz, double m)
  29. {
  30. class Punto* aggiungi_nuovo_punto_P = new Punto(id, vx, vy, vz, m);
  31. this->punti.push_back(*aggiungi_nuovo_punto_P);
  32. }
  33.  
  34. void quantita_di_moto(double& px, double& py, double& pz)
  35. // qui fa il for di tutti gli elementi del vettore e calcola la qta di moto
  36. {
  37.  
  38. for (auto i = this->punti.begin(); i != this->punti.end(); i++) {
  39. double px = (i->vx, 2) * (i->m);
  40. double py = (i->vy, 2) * (i->m);
  41. double pz = (i->vz, 2) * (i->m);
  42.  
  43.  
  44.  
  45. }
  46. }
  47.  
  48. string fastest()
  49. {
  50. float vMax = -3.402822e+38;
  51. string fastest;
  52. for (auto i = this->punti.begin(); i != this->punti.end(); i++)
  53. {
  54. float v = sqrt(pow(i->vx, 2) + pow(i->vy, 2) + pow(i->vz, 2));
  55. if (v > vMax)
  56. {
  57. vMax = v;
  58. fastest = i->id;
  59. }
  60. }
  61. cout << "Punto piu veloce : [" << fastest << "] [velocita = " << vMax << "]\n\n";
  62. return fastest;
  63. }
  64. void Visualizza()
  65. {
  66. cout << "nome: " << id << '\n'
  67. << "qdm: " << px <<py<<pz<< '\n'
  68. << "x_velocity: " << vx << '\n'
  69. << "y_velocity: " << vy << '\n'
  70. << "z_velocity: " << vz << '\n'
  71. << "mass: " << m << "\n\n\n";
  72.  
  73. for (auto i = this->punti.begin(); i != this->punti.end(); i++)
  74. i->Visualizza();
  75. }
  76.  
  77.  
  78. };
  79.  
  80.  
  81.  
  82. int main()
  83. {
  84. Punto* p = new Punto();
  85. p->add("punto 1", 5, 6, 7, 8);
  86. (*p).add("punto 2", 2, 3, 6, 6);
  87. p->add("punto 3", 1, 4, 9, 7);
  88. p->Visualizza();
  89. p->fastest();
  90. p->quantita_di_moto();
  91. //s->qdm();
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement