Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 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;
  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. }
  24.  
  25. void add(string id, double vx, double vy, double vz, double m)
  26. {
  27. class Punto* aggiungi_nuovo_punto_P = new Punto(id, vx, vy, vz, m);
  28. this->punti.push_back(*aggiungi_nuovo_punto_P);
  29. }
  30.  
  31. void qdm(double& px, double& py, double& pz)
  32. {
  33.  
  34. }
  35.  
  36. string fastest()
  37. {
  38. float vMax = -3.402822e+38;
  39. string fastest;
  40. for (auto i = this->punti.begin(); i != this->punti.end(); i++)
  41. {
  42. float v = sqrt(pow(i->vx, 2) + pow(i->vy, 2) + pow(i->vz, 2));
  43. if (v > vMax)
  44. {
  45. vMax = v;
  46. fastest = i->id;
  47. }
  48. }
  49. cout << "Punto piu veloce : [" << fastest << "] [velocita = " << vMax << "]\n\n";
  50. return fastest;
  51. }
  52. void Visualizza()
  53. {
  54. cout << "nome: " << id << '\n'
  55. << "x_velocity: " << vx << '\n'
  56. << "y_velocity: " << vy << '\n'
  57. << "z_velocity: " << vz << '\n'
  58. << "mass: " << m << "\n\n\n";
  59.  
  60. for (auto i = this->punti.begin(); i != this->punti.end(); i++)
  61. i->Visualizza();
  62. }
  63.  
  64.  
  65. };
  66.  
  67.  
  68.  
  69. int main()
  70. {
  71. Punto* p = new Punto();
  72. p->add("punto 1", 5, 6, 7, 8);
  73. (*p).add("punto 2", 2, 3, 6, 6);
  74. p->add("punto 3", 1, 4, 9, 7);
  75. p->Visualizza();
  76. p->fastest();
  77. //s->qdm();
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement