需要帮助编码速度计算器! ! [英] Need help coding a speed calculator! !
问题描述
我对编码非常陌生,我必须计算一个物体的速度,以非恒定的速度沿直线移动。我需要每30秒测量一次速度。我不知道从哪里开始,所有的帮助都表示赞赏。
我尝试了什么:
我不理解的研究
I am very new to coding and I have to calculate the speed of an object, moving in a straight line at a non-constant speed. I need to measure the speed every 30 seconds. I do not know where to start, all help is appreciated.
What I have tried:
research which I do not understand
推荐答案
从数学开始,这很简单:加速度是速度随时间的变化。 />
Start with the maths, it's pretty simple: Acceleration is the change in velocity over time.
Equation: a = (v-u) / t
其中
Where
a is the accelleration
v is the current speed
u is the initial speed
t is the time
(这是来自一个非常非常快的谷歌: 计算加速对象的速度 - Google搜索 [ ^ ]
顶部链接带我到这里: BBC Bitesize - GCSE物理 - 速度,速度和加速度 - 修订版1 [ ^ ]
第3页介绍加速度: BBC Bitesize - GCSE物理 - 速度,速度和加速度 - 修订版3 [ ^ ]
所以要计算任何给定时间的速度,所有你需要做的就是等式:
(This is from a very, very quick google: calculate speed of accelerating object - Google Search[^]
The top link took me here: BBC Bitesize - GCSE Physics - Speed, velocity and acceleration - Revision 1[^]
And page 3 covers acceleration: BBC Bitesize - GCSE Physics - Speed, velocity and acceleration - Revision 3[^]
So to calculate the speed at any given time, all you have to do is rework the equation:
v = (a * t) + u
你知道加速度(或者你不能解决总的来说速度,t每隔一个间隔增加30,你知道初始速度。 (老实说,你可以通过查看所涉及的单位来解决这个问题。加速度是m / s 2 ,速度是m / s所以初始方程非常明显!)
所以你所要做的就是写一个快速循环,每次增加t并打印结果。
如果加速度不恒定,则数学变得更复杂,但Google也可以为您找到。
You know the acceleration (or you can't work out the speed at all), the t is incremented by 30 every interval, and you know the initial speed. (To be honest, you can work this out just by looking at the units involved. Acceleration is in m/s2 and velocity is in m/s so the initial equation is pretty obvious!)
So all you have to do is write a quick loop which increments t and print the results each time interval.
If the acceleration isn't constant, the maths gets more complex, but Google can find that for you as well.
这篇关于需要帮助编码速度计算器! !的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!