|
发表于 2007-12-3 18:53:12
|
显示全部楼层
接受时间的某已经写过了
这里是接受初始速度和加速度的坐标计算
由于WE现在用不了,所以用C++写了
要用的话自己转成WE的,镜头参数的改变和其余的用接受时间的那个的就行
C++语法高亮居然用不了!
typedef struct
{
float x;
float y;
}posi;
bool caculate(posi start,posi obj,float speed,float a)
{
posi dc;
float t;
float dgr;
float dis;
dgr = (float)atandgr( (obj.y - start.y) / (obj.x - start.x) );
if(obj.x - start.x < 0)
dgr += 180;
cout<<"Degree = "<<dgr<<endl;
dis = sqrt( (obj.y - start.y) * (obj.y - start.y) + (obj.x - start.x) * (obj.x - start.x) );
cout<<"Distance = "<<dis<<endl;
if(((2 * speed - a) * (2 * speed - a) + 8 * a * dis) < 0)
{
cout<<"Numberic Error"<<endl;
return false;
}
t = (sqrt((2 * speed - a) * (2 * speed - a) + 8 * a * dis) - 2 * speed - a) / ( 2 * a );
cout<<" Need move "<<t<<" times"<<endl;
int te = 0;
dc.x = start.x;
dc.y = start.y;
while(te<t)
{
cout<<"The "<<te<<"th move"<<endl;
dc.x += (speed + te * a) * cosd(dgr);
dc.y += (speed + te * a) * sind(dgr);
cout<<"Current X "<<dc.x<<" ";
cout<<"Current Y "<<dc.y<<endl;
++te;
}
return true;
} |
|