Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include<list>
- using namespace std;
- class Punto {
- string id;
- double vx, vy, vz, m, px, py, pz;
- list<Punto> punti;
- public:
- Punto(string id = "~", double vx = 0, double vy = 0, double vz = 0, double m = 0)
- {
- (*this).id = id;
- this->vx = vx;
- this->vy = vy;
- this->vz = vz;
- this->m = m;
- this->px = px;
- this->py = py;
- this->pz = pz;
- }
- void add(string id, double vx, double vy, double vz, double m)
- {
- class Punto* aggiungi_nuovo_punto_P = new Punto(id, vx, vy, vz, m);
- this->punti.push_back(*aggiungi_nuovo_punto_P);
- }
- void quantita_di_moto(double& px, double& py, double& pz)
- // qui fa il for di tutti gli elementi del vettore e calcola la qta di moto
- {
- for (auto i = this->punti.begin(); i != this->punti.end(); i++) {
- double px = (i->vx, 2) * (i->m);
- double py = (i->vy, 2) * (i->m);
- double pz = (i->vz, 2) * (i->m);
- }
- }
- string fastest()
- {
- float vMax = -3.402822e+38;
- string fastest;
- for (auto i = this->punti.begin(); i != this->punti.end(); i++)
- {
- float v = sqrt(pow(i->vx, 2) + pow(i->vy, 2) + pow(i->vz, 2));
- if (v > vMax)
- {
- vMax = v;
- fastest = i->id;
- }
- }
- cout << "Punto piu veloce : [" << fastest << "] [velocita = " << vMax << "]\n\n";
- return fastest;
- }
- void Visualizza()
- {
- cout << "nome: " << id << '\n'
- << "qdm: " << px <<py<<pz<< '\n'
- << "x_velocity: " << vx << '\n'
- << "y_velocity: " << vy << '\n'
- << "z_velocity: " << vz << '\n'
- << "mass: " << m << "\n\n\n";
- for (auto i = this->punti.begin(); i != this->punti.end(); i++)
- i->Visualizza();
- }
- };
- int main()
- {
- Punto* p = new Punto();
- p->add("punto 1", 5, 6, 7, 8);
- (*p).add("punto 2", 2, 3, 6, 6);
- p->add("punto 3", 1, 4, 9, 7);
- p->Visualizza();
- p->fastest();
- p->quantita_di_moto();
- //s->qdm();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement