Stream operator for Ball

This commit is contained in:
Rémi Oudin 2018-02-12 01:11:23 +01:00
parent 80f0e96acf
commit 006d2de34a
2 changed files with 13 additions and 1 deletions

View file

@ -1,4 +1,5 @@
#include "Ball.hpp" #include "Ball.hpp"
#include <iostream>
#include <cmath> #include <cmath>
Ball::Ball(Point& _center, double _v_x, double _p, double _q) : Ball::Ball(Point& _center, double _v_x, double _p, double _q) :
@ -52,3 +53,11 @@ void Ball::update_pos(double dt) {
} }
_compute_pos(dt); _compute_pos(dt);
} }
std::ostream& operator<< (std::ostream &out, Ball const& data) {
Point center = data.getCenter();
out << center.x << ':';
out << center.y << ':';
out << center.z << '\n';
return out;
}

View file

@ -9,7 +9,7 @@
* each bounce, which is a reasonable assumption since it is the same for the * each bounce, which is a reasonable assumption since it is the same for the
* vertical bounces. * vertical bounces.
**/ **/
#pragma once
#include <cstddef> #include <cstddef>
#include "spheroid.hpp" #include "spheroid.hpp"
@ -33,4 +33,7 @@ class Ball {
public: public:
Ball(Point& _center, double _v_x, double p, double q); Ball(Point& _center, double _v_x, double p, double q);
void update_pos(double dt); void update_pos(double dt);
Point getCenter() const {return Center;}
}; };
std::ostream& operator << (std::ostream &out, Ball const& data);