## Resampling

Algorithm : Upsampling
Input : { v [ k ] = ( x [ k ] , y [ k ] , t [ k ] ) , 0 ≤ k ≤ n } \left\{ v\lbrack k\rbrack = \left( x\lbrack k\rbrack,y\lbrack k\rbrack,t\lbrack k\rbrack \right),0 \leq k \leq n \right\} and a target rate `sampling_min_output_rate`, Interpolate time and position between each k k by linearly adding interpolated values
This is done by adding linearly interpolated values so that the output stream is { v [ 0 ] , u 0 [ 1 ] , … , u 0 [ n 0 − 1 ] ⏟ interpolated , v [ 1 ] , u 1 [ 1 ] , … , u 1 [ n 1 − 1 ] ⏟ interpolated , v [ 2 ] , … } \left\{ v\lbrack 0\rbrack,\underset{\text{ interpolated}}{\underbrace{u_{0}\lbrack 1\rbrack,\ldots,u_{0}\left\lbrack n_{0} - 1 \right\rbrack}},v\lbrack 1\rbrack,\underset{\text{ interpolated}}{\underbrace{u_{1}\lbrack 1\rbrack,\ldots,u_{1}\left\lbrack n_{1} - 1 \right\rbrack}},v\lbrack 2\rbrack,\ldots \right\} Each n i n_{i} is the minimum integer such that t [ i ] − t [ i − 1 ] n i < Δ target ⇔ n i = ⌈ t [ i + 1 ] − t [ i ] Δ target ⌉ \begin{aligned} & \frac{t\lbrack i\rbrack - t\lbrack i - 1\rbrack}{n_{i}} < \Delta_{\text{target}} \\ \Leftrightarrow & n_{i} = \left\lceil \frac{t\lbrack i + 1\rbrack - t\lbrack i\rbrack}{\Delta_{\text{target}}} \right\rceil \end{aligned} and the linear interpolation means u j [ k ] = ( 1 − k n j ) v [ j ] + k n i v [ j + 1 ] u_{j}\lbrack k\rbrack = \left( 1 - \frac{k}{n_{j}} \right)v\lbrack j\rbrack + \frac{k}{n_{i}}v\lbrack j + 1\rbrack
Output : { ( x ′ [ k ′ ] , y ′ [ k ′ ] , t ′ [ k ′ ] ) , 0 ≤ k ; ≤ n ′ } \left\{ \left( x\prime\lbrack k\prime\rbrack,y\prime\lbrack k\prime\rbrack,t\prime\lbrack k\prime\rbrack \right),0 \leq k; \leq n\prime \right\} the upsampled position and times. This verifies ∀ k ′ , t ′ [ k ′ ] − t ′ [ k ′ − 1 ] < Δ target = 1 sampling_min_output_rate \forall k\prime,t\prime\lbrack k\prime\rbrack - t\prime\lbrack k\prime - 1\rbrack < \Delta_{\text{target }} = \frac{1}{\text{sampling_min_output_rate}}
Remark : As this is a streaming algorithm, we only calculate this interpolation with respect to the latest stroke position.