| 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 comment(body) = [#text(size: 0.8em)[(#body)]] |
| 5 |
|
| 6 |
#let pr = $nu$ |
| 7 |
#let time = $t$ |
| 8 |
|
| 9 |
== Stylus state modeler |
| 10 |
|
| 11 |
Up till now we have only used the raw input stream to create a new smoothed stream of positions, leaving behind the |
| 12 |
pressure attribute. This is what's done here, to model the state of the stylus for these new position based on the |
| 13 |
pressure data of the raw input strokes.\ |
| 14 |
|
| 15 |
*Algorithm* #[Stylus state modeler]\ |
| 16 |
#[*Input* : |
| 17 |
- input stream with pressure information ${(p[k]=(x[k],y[k]),pr[k]),0 <=k <= n}$ |
| 18 |
- query position $q = (x,y)$ |
| 19 |
- search window $n_"search"$ #comment[From `stylus_state_modeler_max_input_samples`], |
| 20 |
]\ |
| 21 |
#[*initialize* $d = oo$, $"index"="None"$, $"interp" = "None"$]\ |
| 22 |
#[*for* $i=n-n_"search"$ to $n-1$ *do*]\ |
| 23 |
- #[*Find* $q_i$ the position that's closest to $q$ on the segment $[p[i],p[i+1]]$ and denote $r in [0,1]$ the value such |
| 24 |
that $ |
| 25 |
q_i = (1-r) p[i] + r p[i+1]$]\ |
| 26 |
- #[*if* $norm(q - q_i) < d$]\ |
| 27 |
- #[$d <- norm(q - q_i) < d\ |
| 28 |
"index" =i\ |
| 29 |
"interp" = r $]\ |
| 30 |
- #[*endif*]\ |
| 31 |
#[*endfor*]\ |
| 32 |
#[*calculate* $ |
| 33 |
pr = (1-r) pr["index"] + r pr["index" +1] |
| 34 |
$]\ |
| 35 |
#[*Output* : interpolated pressure $pr$] |