Debian Codegraph @

docs/position_modeling.typ

raw
1 #set page(width: 16cm, margin: 0.5em, height: auto)
2 #let definition(content) = box(fill: luma(92%), width: 100%, inset: 0.5em, stroke: black)[#content]
3
4 #let pr = $nu$
5 #let time = $t$
6
7 == Position modeling
8
9 #definition[The raw input is processed as follow
10
11 raw input $->$ wobble smoother $->$ upsampled $->$ position modeling]
12
13 #definition[
14 The position of the pen is modeled as a weight connected by a spring to an anchor.
15
16 The anchor moves along the _resampled dewobbled inputs_, pulling the weight along with it across a surface, with some
17 amount of friction. Euler integration is used to solve for the position of the pen.
18
19 #figure(image("position_model.svg"))
20
21 The physical model that is used to model the stroke is the following
22 $
23 (dif^2 s) / (dif t^2) = (Phi(t) - s(t)) / k_"spring" - k_"drag" (dif s) / (dif t)
24 $
25 where
26 - $t$ is time
27 - $s(t)$ is the position of the pen
28 - $Phi(t)$ is the position of the anchor
29 - $k_"spring"$ and $k_"drag"$ are constants that sets how the spring and drag occurs
30
31 $k_"spring"$ is given by `position_modeler_spring_mass_constant` and $k_"drag"$ by `position_modeler_drag_constant`
32
33 We will thus have as input the _upsampled dewobbled inputs_ taking the role of discretized $Phi(t)$ and $s(t)$ will be
34 the output
35 ]
36
37 #definition[
38 Modeling a stroke.
39 - Input : input stream ${(p[k],t[k]), 0 <= k <=n}$
40 - Output : smoothed stream ${(p_f [k],v_f [k],a_f [k]), 0 <= k <=n}$
41 We define $Phi[k] = p[k]$. An euler scheme integration scheme is used with the initial conditions being $v[0] = 0$ and $p_f [0] = p[0]$ (same
42 initial conditions)
43
44 Update rule is simply
45 $
46 a_f [j] = (p[j]- p_f [j-1]) / k_"spring" - k_"drag" v_f [j-1]\
47 v_f [j] = v_f [j-1] + (t[j]-t[j-1])a_f [j]\
48 p_f [j] = p_f [j-1] + (t[j]-t[j-1])v_f [j]
49 $
50 The position $s[j]$ is the main thing to export but we can also export speed and acceleration if needed. We denote
51 $
52 q[j] = (p_f [j],v_f [j],a_f [j],t[j])
53 $
54 and this will be our output with $0 <= j <= n$
55 ]