Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在斜坡上弹跳的弹性粒子_C++_Dev C++ - Fatal编程技术网

C++ 在斜坡上弹跳的弹性粒子

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

我试图模拟一个弹性粒子在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)
//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;
}