FEATURES APPLICATIONS DOWNLOADS EDUCATION BLOG WIKI FORUM STORE

## Calculating velocity/acceleration

General discussion about anything TouchDesigner

### Calculating velocity/acceleration

Hi - I'm trying to calculate the velocity and acceleration of a generic chop input. I'm shaky with the math, but since my intention to look at this frame by frame (making time=1), I'm doing:

where input[0] is the latest sample in the channel

vel1 = input[0] - input[1]
vel2 = input[1] - input[2]

acceleration1 = vel1-vel2

I've made a simple tox to do these calculations but I'm seeing some weird results. When I feed it a ramp pattern, velocity and acceleration values vary just ever so slightly. I've attached the tox and would appreciate a look to see if this is the proper way to do these calculations. I'm using delay chops, specifying delays in frames, and maths rather than python to do the calculations.

thanks!
b
Attachments
accel_test.tox
bnew

Posts: 22
Joined: Tue Dec 19, 2017 8:40 pm

### Re: Calculating velocity/acceleration

You could compare your results with a slopeCHOP

https://docs.derivative.ca/Slope_CHOP

(+ use trailCHOP with a fixed viewer to visualize)
// Philippe Provencher
guarana

Posts: 80
Joined: Sun Apr 27, 2014 10:13 pm

### Re: Calculating velocity/acceleration

Thank you! Did not know the 'slope' chop existed... I am seeing some of the same artifacts but far less. Anyone have any ideas of why it would be doing this?

Here's how the data looks. First column is speed, second acceleration. Sometimes I get weird little blips in acceleration and/or velocity. Maybe its just because im feeding this with a pattern.
Screen Shot 2019-04-17 at 6.18.49 PM.png (28.55 KiB) Viewed 134 times

Screen Shot 2019-04-17 at 6.20.55 PM.png (78.09 KiB) Viewed 134 times

tox attached as well.
Attachments
slopeTest.tox
bnew

Posts: 22
Joined: Tue Dec 19, 2017 8:40 pm

### Re: Calculating velocity/acceleration

The glitch is happening as the timeline wraps around.
Specifically the value in pattern1 drops from 1 to 0 at that time.

The slight variations in value are likely due to the limits of floating point precision happening in the CHOPs.

Hope that helps,
Rob

rob
Staff

Posts: 1621
Joined: Tue Nov 13, 2007 1:14 am