Y axis is vertical for OpenGL
This commit is contained in:
parent
1ee6875b5a
commit
26cac772d7
3 changed files with 9 additions and 9 deletions
12
Ball.cpp
12
Ball.cpp
|
@ -5,20 +5,20 @@
|
||||||
Ball::Ball(Point& _center, double _min_height, double _v_x, double _p, double _q) :
|
Ball::Ball(Point& _center, double _min_height, double _v_x, double _p, double _q) :
|
||||||
Center(_center),
|
Center(_center),
|
||||||
surface(_center, min_height, _p, _q),
|
surface(_center, min_height, _p, _q),
|
||||||
init_h(_center.z),
|
init_h(_center.y),
|
||||||
min_height(_min_height),
|
min_height(_min_height),
|
||||||
bounce_number(0.0),
|
bounce_number(0.0),
|
||||||
crt_time(0),
|
crt_time(0),
|
||||||
A(_center.z),
|
A(_center.y),
|
||||||
B(0),
|
B(0),
|
||||||
U(sqrt(2 * G_CTE * _center.z)),
|
U(sqrt(2 * G_CTE * _center.y)),
|
||||||
T(sqrt(2.0 * _center.z / G_CTE)),
|
T(sqrt(2.0 * _center.y / G_CTE)),
|
||||||
v_x(_v_x)
|
v_x(_v_x)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ball::_compute_pos(double dt) {
|
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;
|
Center.x += dt * v_x;
|
||||||
surface.update_center_pos(Center);
|
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.access_crt_time() << ":";
|
||||||
out << "T:" << data.accessT() << ":";
|
out << "T:" << data.accessT() << ":";
|
||||||
out << center.x << ':';
|
out << center.x << ':';
|
||||||
out << center.y << ':';
|
|
||||||
out << center.z << ':';
|
out << center.z << ':';
|
||||||
|
out << center.y << ':';
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ using namespace std;
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
int i;
|
int i;
|
||||||
Point center(0,0,10);
|
Point center(0,10,0);
|
||||||
Ball ball(center, 0, 0.25, 1, 1);
|
Ball ball(center, 0, 0.25, 1, 1);
|
||||||
for(i=0; i< 10000; i++) {
|
for(i=0; i< 10000; i++) {
|
||||||
ball.update_pos(0.001);
|
ball.update_pos(0.001);
|
||||||
|
|
|
@ -29,8 +29,8 @@ void Spheroid::update_center_pos(Point& _center) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spheroid::check_horizontal_plan_collision(double& height) {
|
void Spheroid::check_horizontal_plan_collision(double& height) {
|
||||||
if ((center.z - p) <= height) {
|
if ((center.y - p) <= height) {
|
||||||
p = fmin(init_p, center.z-height);
|
p = fmin(init_p, center.y-height);
|
||||||
update_radius();
|
update_radius();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue