PositionSpeed
Calculates the position speed from X and Y coordinate variables and creates a new continuous variable.
Syntax
PositionSpeed(varX, varY, deltaT, smoothRadius)
Parameters
Parameter |
Type |
Description |
---|---|---|
varX |
variableReference |
Reference to the variable. |
varY |
variableReference |
Reference to the variable. |
deltaT |
number |
Time step for speed calculation |
smoothRadius |
number |
Smooth parameter. See Comments. |
Return
Reference to the new variable
Note
PositionSpeed operation calculates the scalar speed of a pair of the position variables.
First, for each data point of a Position variable
PosX[T]
, whereT
is time, the raw scalar speed is calculated:
dX = PosX[ T + DeltaT ] - PosX[ T ]
dY = PosY[ T + DeltaT ] - PosY[ T ]
RawScalarSpeed[ T ] = sqrt( dX*dX + dY*dY ) / DeltaT
If there is no data point at time T+DeltaT
, a linear interpolation is used to calculate PosX[T + DeltaT]
and PosY[T + DeltaT]
.
Second,
RawScalarSpeed
is smoothed with the Gaussian filter. The parameters of the filter are such that the width (in seconds) of the Gaussian curve at half the height is equal to the value of Smooth parameter. If Smooth = 0, Gaussian filter is not applied.
Examples
Python
import nex
doc = nex.GetActiveDocument()
doc["speed"] = nex.PositionSpeed(doc["LED1_X"], doc["LED1_Y"], 0.1, 0.5)
NexScript
doc = GetActiveDocument()
doc["speed"] = PositionSpeed(doc["LED1_X"], doc["LED1_Y"], 0.1, 0.5)