Y axis is vertical for OpenGL

This commit is contained in:
Rémi Oudin 2018-02-12 18:18:28 +01:00
parent 1ee6875b5a
commit 26cac772d7
3 changed files with 9 additions and 9 deletions

View file

@ -5,20 +5,20 @@
Ball::Ball(Point& _center, double _min_height, double _v_x, double _p, double _q) :
Center(_center),
surface(_center, min_height, _p, _q),
init_h(_center.z),
init_h(_center.y),
min_height(_min_height),
bounce_number(0.0),
crt_time(0),
A(_center.z),
A(_center.y),
B(0),
U(sqrt(2 * G_CTE * _center.z)),
T(sqrt(2.0 * _center.z / G_CTE)),
U(sqrt(2 * G_CTE * _center.y)),
T(sqrt(2.0 * _center.y / G_CTE)),
v_x(_v_x)
{
}
void Ball::_compute_pos(double dt) {
Center.z = fmax(0.0, A + B * crt_time - (G_CTE / 2) * crt_time * crt_time + min_height);
Center.y = fmax(0.0, A + B * crt_time - (G_CTE / 2) * crt_time * crt_time + min_height);
Center.x += dt * v_x;
surface.update_center_pos(Center);
}
@ -66,7 +66,7 @@ std::ostream& operator<< (std::ostream &out, Ball const& data) {
out << "t:" << data.access_crt_time() << ":";
out << "T:" << data.accessT() << ":";
out << center.x << ':';
out << center.y << ':';
out << center.z << ':';
out << center.y << ':';
return out;
}

View file

@ -10,7 +10,7 @@ using namespace std;
int main(int argc, char** argv) {
int i;
Point center(0,0,10);
Point center(0,10,0);
Ball ball(center, 0, 0.25, 1, 1);
for(i=0; i< 10000; i++) {
ball.update_pos(0.001);

View file

@ -29,8 +29,8 @@ void Spheroid::update_center_pos(Point& _center) {
}
void Spheroid::check_horizontal_plan_collision(double& height) {
if ((center.z - p) <= height) {
p = fmin(init_p, center.z-height);
if ((center.y - p) <= height) {
p = fmin(init_p, center.y-height);
update_radius();
}
}