Stream operator for Ball
This commit is contained in:
parent
80f0e96acf
commit
006d2de34a
2 changed files with 13 additions and 1 deletions
9
Ball.cpp
9
Ball.cpp
|
@ -1,4 +1,5 @@
|
|||
#include "Ball.hpp"
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
Ball::Ball(Point& _center, double _v_x, double _p, double _q) :
|
||||
|
@ -52,3 +53,11 @@ void Ball::update_pos(double 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;
|
||||
}
|
||||
|
|
5
Ball.hpp
5
Ball.hpp
|
@ -9,7 +9,7 @@
|
|||
* each bounce, which is a reasonable assumption since it is the same for the
|
||||
* vertical bounces.
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include "spheroid.hpp"
|
||||
|
||||
|
@ -33,4 +33,7 @@ class Ball {
|
|||
public:
|
||||
Ball(Point& _center, double _v_x, double p, double q);
|
||||
void update_pos(double dt);
|
||||
Point getCenter() const {return Center;}
|
||||
};
|
||||
|
||||
std::ostream& operator << (std::ostream &out, Ball const& data);
|
||||
|
|
Loading…
Reference in a new issue