Position modeling

The raw input is processed as follow

raw input \rightarrow wobble smoother \rightarrow upsampled \rightarrow position modeling

The position of the pen is modeled as a weight connected by a spring to an anchor.

The anchor moves along the resampled dewobbled inputs, pulling the weight along with it across a surface, with some amount of friction. Euler integration is used to solve for the position of the pen.

The physical model that is used to model the stroke is the following d 2 s d t 2 = Φ ( t ) s ( t ) k spring k drag d s d t \frac{d^{2}s}{dt^{2}} = \frac{\Phi(t) - s(t)}{k_{\text{spring }}} - k_{\text{drag }}\frac{ds}{dt} where

k spring k_{\text{spring}} is given by position_modeler_spring_mass_constant and k drag k_{\text{drag}} by position_modeler_drag_constant

We will thus have as input the upsampled dewobbled inputs taking the role of discretized Φ ( t ) \Phi(t) and s ( t ) s(t) will be the output

Modeling a stroke.

We define Φ [ k ] = p [ k ] \Phi\lbrack k\rbrack = p\lbrack k\rbrack . An euler scheme integration scheme is used with the initial conditions being v [ 0 ] = 0 v\lbrack 0\rbrack = 0 and p f [ 0 ] = p [ 0 ] p_{f}\lbrack 0\rbrack = p\lbrack 0\rbrack (same initial conditions)

Update rule is simply a f [ j ] = p [ j ] p f [ j 1 ] k spring k drag v f [ j 1 ] v f [ j ] = v f [ j 1 ] + ( t [ j ] t [ j 1 ] ) a f [ j ] p f [ j ] = p f [ j 1 ] + ( t [ j ] t [ j 1 ] ) v f [ j ] \begin{array}{r} a_{f}\lbrack j\rbrack = \frac{p\lbrack j\rbrack - p_{f}\lbrack j - 1\rbrack}{k_{\text{spring }}} - k_{\text{drag }}v_{f}\lbrack j - 1\rbrack \\ v_{f}\lbrack j\rbrack = v_{f}\lbrack j - 1\rbrack + \left( t\lbrack j\rbrack - t\lbrack j - 1\rbrack \right)a_{f}\lbrack j\rbrack \\ p_{f}\lbrack j\rbrack = p_{f}\lbrack j - 1\rbrack + \left( t\lbrack j\rbrack - t\lbrack j - 1\rbrack \right)v_{f}\lbrack j\rbrack \end{array} The position s [ j ] s\lbrack j\rbrack is the main thing to export but we can also export speed and acceleration if needed. We denote q [ j ] = ( p f [ j ] , v f [ j ] , a f [ j ] , t [ j ] ) q\lbrack j\rbrack = \left( p_{f}\lbrack j\rbrack,v_{f}\lbrack j\rbrack,a_{f}\lbrack j\rbrack,t\lbrack j\rbrack \right) and this will be our output with 0 j n 0 \leq j \leq n