#include
class Vastu{
public:
float x;
float y;
float vx;
float vy;
float ax;
float ay;
float fx;
float fy;
float m;
char name[];
Vastu(float x,float y,float vx , float vy, float ax,float ay,float fx,float fy,float m){
x = x;
y = y;
vx = vx;
vy = vy;
ax = ax;
ay = ay;
fx = fx;
fy = fy;
m = m;
}
void tick(float dt){
updateState(dt);
printf("%f , %f \n",x,y);
}
void printState(){
printf("x:%f y:%f vx:%f vy:%f ax:%f ay:%f fx:%f fy:%f m:%f",x,y,vx,vy,ax,ay,fx,fy,m);
}
private :
void updateState(float dt){
ax = ax + (fx/m);
ay = ay + (fy/m);
vx = vx + ax*dt;
vy = vy + ay*dt;
x = x + vx*dt;
y = y + vy*dt;
}
};
int main(){
Vastu gota(0,0,10,20,0,0,0,-10,1);
gota.printState();
}
im tring to make a phy simulation in this case projectile motion.
when we call the func tick() which takes time as input it will update the coordinates and print them.\
but instead of 0 and 1 or things like that all its printing is 235529233934397170000000000000000.000000 and -1.#QNAN0 for almost all the variables.
m = m; } void tick(float dt){ updateState(dt); printf("%f , %f \n",x,y); } void printState(){ printf("x:%f y:%f vx:%f vy:%f ax:%f ay:%f fx:%f fy:%f m:%f",x,y,vx,vy,ax,ay,fx,fy,m); } private : void updateState(float dt){ ax = ax + (fx/m); ay = ay + (fy/m);
vx = vx + ax*dt; vy = vy + ay*dt;
x = x + vx*dt; y = y + vy*dt; } };
int main(){ Vastu gota(0,0,10,20,0,0,0,-10,1); gota.printState(); } [/code] im tring to make a phy simulation in this case projectile motion. when we call the func tick() which takes time as input it will update the coordinates and print them.\ but instead of 0 and 1 or things like that all its printing is 235529233934397170000000000000000.000000 and -1.#QNAN0 for almost all the variables.