计算一定时间后加速物体的位置 [英] Calculate the position of an accelerating body after a certain time

查看:82
本文介绍了计算一定时间后加速物体的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一定时间(例如1秒)之后,如何计算加速物体(例如汽车)的位置?

How do I calculate the position of an accelerating body (e.g. a car) after a certain time (e.g. 1 second)?

对于一个不加速的运动物体,它是线性关系,所以我假设对于一个加速物体,它在某处涉及一个正方形.

For a moving body that it not accelerating, it is a linear relationship, so I presume for an accelerating body it involves a square somewhere.

有什么想法吗?

推荐答案

等式为:s = ut +(1/2)a t ^ 2

The equation is: s = ut + (1/2)a t^2

其中s是位置,u是在t = 0处的速度,t是时间,a是恒定加速度.

where s is position, u is velocity at t=0, t is time and a is a constant acceleration.

例如,如果汽车在静止状态下起步,并以3m/s ^ 2的加速度加速了两秒钟,它就会移动(1/2)* 3 * 2 ^ 2 = 6m

For example, if a car starts off stationary, and accelerates for two seconds with an acceleration of 3m/s^2, it moves (1/2) * 3 * 2^2 = 6m

该方程式是通过对方程式进行分析积分得出的,该方程式表示速度是位置的变化率,而加速度是速度的变化率.

This equation comes from integrating analytically the equations stating that velocity is the rate-of-change of position, and acceleration is the rate-of-change of velocity.

通常在游戏编程的情况下,会使用略有不同的表述:在每一帧中,速度和位置的变量不是通过分析而是通过数字进行积分:

Usually in a game-programming situation, one would use a slightly different formulation: at every frame, the variables for velocity and position are integrated not analytically, but numerically:

s = s + u * dt;
u = u + a * dt;

其中dt是一帧的长度(使用计时器测量:1/60秒左右).这种方法的优点是加速度可以随时间变化.

where dt is the length of a frame (measured using a timer: 1/60th second or so). This method has the advantage that the acceleration can vary in time.

编辑几个人已经注意到,尽管最简单的论证方法是Euler数值积分法(如下所示),但其准确性却很差.请参见速度Verlet (通常在游戏中使用)和

Edit A couple of people have noted that the Euler method of numerical integration (as shown here), though the simplest to demonstrate with, has fairly poor accuracy. See Velocity Verlet (often used in games), and 4th order Runge Kutta (a 'standard' method for scientific applications) for improved algorithms.

这篇关于计算一定时间后加速物体的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆