
Okay, so I have a pretty complicated question, but I think that some of the smart people that are on Frihost will probably be able to figure it out.
Here's the scenario.
Let's say that I have a graph which has acceleration in m/s^2 on the yaxis and time in seconds on the xaxis. Now, the graph isn't going to be some consistent function that's easy to calculate; there could be random spikes and changes in acceleration, and there would be a fair amount of jitter.
With that graph, is there any way that I could calculate displacement?
Thanks,
Nick
Break the area up into triangles, then find the area (displacement) of each triangle, then add them all together?
That would probably be easiest if you're trying to program a computer to do it.
Or, if you actually meant distance, like in the title, it would just be a matter of:
Code: 
$distance = <calculate distance between first two points>
$total = $distance
WHILE <there are more points>
$distance = <calculate distance between the next two points>
$total = $total + $distance
END WHILE
echo ($total)

Hmmm... I did kind of contradict myself there. Well, my end goal is to create an app that measures distances using the accelerometer on a cell phones. I did some pretty extensive testing and found that even though the results were extremely jittery, they were still very accurate.
In this case, displacement and distance traveled are pretty much the same thing because there will be almost no movement in a negative direction. I'll have to figure out the best approach. If I can make the graph less jittery, I will simply calculate the distance from point to point. Otherwise, I'll just do displacement.
Thanks ocalhoun!
Nick
pollygone wrote:  If I can make the graph less jittery, I will simply calculate the distance from point to point. 
All you need to do is reduce the sampling interval for the points... This will result in a less jittery, easier to handle, but slightly less accurate graph.
If it's going to be on a phone, processing power will probably be a bit of an issue, so infrequent points would be best.
Heck, maybe even let the users set their own interval?
(Just give them a little slider control labeled <accuracy><speed>)
*edit*
If it's going to be done in realtime, as the graph is made, it might be simpler. You could just add the distance between the previous point and the current point to a total every time you plot a new point on the graph.
Doing that, I think even a (fancy) phone could still handle plotting a new point every few milliseconds.
