C++ 在斜坡上弹跳的弹性粒子
我试图模拟一个弹性粒子在600x600窗口上反弹(graphics.h) 我已经有一个工作条件,当它反弹离地板或墙壁,但我不能使它在斜坡上正确反弹 以下是斜坡的条件:C++ 在斜坡上弹跳的弹性粒子,c++,dev-c++,C++,Dev C++,我试图模拟一个弹性粒子在600x600窗口上反弹(graphics.h) 我已经有一个工作条件,当它反弹离地板或墙壁,但我不能使它在斜坡上正确反弹 以下是斜坡的条件: if(y <= ((3.0/7.0)*x - 90.0/7.0)) //y = 3x/7 - 90/7 is the equation of the line { //by rotating the reference coordinates (the wedge becomes the new x axis) //form
if(y <= ((3.0/7.0)*x - 90.0/7.0)) //y = 3x/7 - 90/7 is the equation of the line
{
//by rotating the reference coordinates (the wedge becomes the new x axis)
//formula:
//x' = xcos(theta) - ysin(theta)
//y' = xsin(theta) + ycos(theta)
Vx = (Vx*(cos(theta)) - (Vy*(sin(theta))));
Vy = -(Vx*(sin(theta)) + (Vy*(cos(theta))));
}
我认为Vx被赋予了一个新的值。然后在下一行的Vy分配中使用。应使用Vx的旧值。所以你需要vxtemp=vx;并在计算中使用VXTEM 看这张照片,似乎相反的角度会起作用
//convert to pixel value (scale of 6)
double conx(double x)
{
return x * (600/100) + 50;
}
double cony(double y)
{
return -y * (600/100) + 650;
}