Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/160.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++ openframeworks,通过向量进行简单的圆周运动_C++_Openframeworks - Fatal编程技术网

C++ openframeworks,通过向量进行简单的圆周运动

C++ openframeworks,通过向量进行简单的圆周运动,c++,openframeworks,C++,Openframeworks,我在OpenFrameworks教程页面上浏览了vectors教程并做了一些实验。使用我编写的代码,我发现圆在到达目的地时会减速,就像它的去加速一样。为什么即使我没有编写任何去加速代码,它也会去加速? 代码如下: #inlcude"testApp.h" ofVec2f V1(500,500); ofVec2f V2(500,500); ofVec2f V3(2,2); void testApp::draw(){ ofEnableSmoothing(); ofSetColor(0, 0,

我在OpenFrameworks教程页面上浏览了vectors教程并做了一些实验。使用我编写的代码,我发现圆在到达目的地时会减速,就像它的去加速一样。为什么即使我没有编写任何去加速代码,它也会去加速? 代码如下:

#inlcude"testApp.h"

ofVec2f V1(500,500);
ofVec2f V2(500,500);
ofVec2f V3(2,2);

void testApp::draw(){

ofEnableSmoothing();

ofSetColor(0, 0, 0);
ofFill();

ofCircle(V1[0], V1[1], 10);

if(V1[0] < 3 && V1[1] < 3)
{
    V1 = V2;
}
else
{
    V1 = V1 + (0.009)*(V3 - V1);
}

ofSetColor(0, 0, 0);
ofFill();
ofCircle(144, 900, 10);

}
#包含“testApp.h”
ofVec2f V1(500500);
ofVec2f V2(500500);
ofvec2fv3(2,2);
void testApp::draw(){
不稳定情绪();
设置颜色(0,0,0);
ofFill();
(V1[0],V1[1],10);
如果(V1[0]<3&&V1[1]<3)
{
V1=V2;
}
其他的
{
V1=V1+(0.009)*(V3-V1);
}
设置颜色(0,0,0);
ofFill();
圆形的(144900,10);
}

每一帧,您将V1向V3移动V1和V3之间距离的0.9%。(
V1=V1+(0.009)*(V3-V1);

随着V1越来越接近V3,
0.009*(V3-V1)
也越来越小,所以您实际上编写了减速代码:)