Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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
Posted
Updated 30-Jun-16 8:20am
Comments
Marcus Kramer 30-Jun-16 14:03pm    
Is it the "How do I calculate this" that is the problem, or the "How do I implement my calculation in code"?
Dave Kreskowiak 30-Jun-16 14:17pm    
You never said which part of this you're having a problem with. How are you "measuring" this speed? What "object" are you talking about? How are you obtaining this data?
[no name] 30-Jun-16 14:22pm    
Could you explain your question briefly please? Is the value of the speed given or should be calculated?
Philippe Mori 30-Jun-16 15:52pm    
What information do you have? If you know the position, you can easily compute average speed for the last 30 seconds.

If this is not what you want, you have to tell us what you want and which information is available.

If you don't provide required information, you will probably get an average vote of 1...

1 solution

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
(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
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.
 
Share this answer
 
Comments
[no name] 30-Jun-16 14:31pm    
Sir, The top link contains malicious java script files(Trojan) fortunately my antivirus blocked. I think it is not false positive because something tried to download refer below. https://www.dropbox.com/s/kl3t5qsunathvfg/Screenshot%20%2851%29.png?dl=0 Kindly perform a scan in your computer
OriginalGriff 30-Jun-16 14:38pm    
I don't think it's my end: kaspersky says no problem, and an inspection of the element says it's a standard google link:

https://www.google.co.uk/search?
q=calculate+speed+of+accelerating+object&
oq=calculate+speed+of+accelerating+object&
aqs=chrome..69i57j69i60&
sourceid=chrome&
ie=UTF-8"
[no name] 30-Jun-16 14:45pm    
Sir, I too use Kaspersky[Updated less than one hour] the you can see the screenshot with the link as malicious
Dave Kreskowiak 30-Jun-16 15:19pm    
The first link in his post a the result of a Google search. It's NOT malicious.
[no name] 30-Jun-16 21:48pm    
Sir, I told the top link from BBC sorry for the mistake

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900