| 1 | <h2>Stroke end</h2> |
| 2 | <p>The position modeling algorithm will lag behind the raw input by some |
| 3 | distance. This algorithm iterates the previous dynamical system a few |
| 4 | additional time using the raw input position as the anchor to allow a |
| 5 | <code>catch up</code> of the stroke (though this prediction is only |
| 6 | given by <code>predict</code>, so is not part of the |
| 7 | <code>results</code> and becomes obsolete on the next input). |
| 8 | </p> |
| 9 | <p><strong>Algorithm</strong> :Stroke end<br /> |
| 10 | <strong>Input</strong>: |
| 11 | </p> |
| 12 | <ul> |
| 13 | <li> |
| 14 | <p>Final anchor position |
| 15 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 16 | <semantics> |
| 17 | <mrow> |
| 18 | <mi>p</mi> |
| 19 | <mrow> |
| 20 | <mo stretchy="true" form="prefix">[</mo> |
| 21 | <mtext mathvariant="normal">end</mtext> |
| 22 | <mo stretchy="true" form="postfix">]</mo> |
| 23 | </mrow> |
| 24 | <mo>=</mo> |
| 25 | <mrow> |
| 26 | <mo stretchy="true" form="prefix">(</mo> |
| 27 | <mi>x</mi> |
| 28 | <mrow> |
| 29 | <mo stretchy="true" form="prefix">[</mo> |
| 30 | <mtext mathvariant="normal">end</mtext> |
| 31 | <mo stretchy="true" form="postfix">]</mo> |
| 32 | </mrow> |
| 33 | <mo>,</mo> |
| 34 | <mi>y</mi> |
| 35 | <mrow> |
| 36 | <mo stretchy="true" form="prefix">[</mo> |
| 37 | <mtext mathvariant="normal">end</mtext> |
| 38 | <mo stretchy="true" form="postfix">]</mo> |
| 39 | </mrow> |
| 40 | <mo stretchy="true" form="postfix">)</mo> |
| 41 | </mrow> |
| 42 | </mrow> |
| 43 | <annotation encoding="application/x-tex">p\left\lbrack \text{end} \right\rbrack = \left( |
| 44 | x\left\lbrack \text{end} \right\rbrack,y\left\lbrack \text{end} \right\rbrack \right) |
| 45 | </annotation> |
| 46 | </semantics> |
| 47 | </math> |
| 48 | (From the original input stream) |
| 49 | </p> |
| 50 | </li> |
| 51 | <li> |
| 52 | <p>final tip state |
| 53 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 54 | <semantics> |
| 55 | <mrow> |
| 56 | <msub> |
| 57 | <mi>q</mi> |
| 58 | <mi>f</mi> |
| 59 | </msub> |
| 60 | <mrow> |
| 61 | <mo stretchy="true" form="prefix">[</mo> |
| 62 | <mtext mathvariant="normal">end</mtext> |
| 63 | <mo stretchy="true" form="postfix">]</mo> |
| 64 | </mrow> |
| 65 | <mo>=</mo> |
| 66 | <mrow> |
| 67 | <mo stretchy="true" form="prefix">(</mo> |
| 68 | <msub> |
| 69 | <mi>p</mi> |
| 70 | <mi>f</mi> |
| 71 | </msub> |
| 72 | <mrow> |
| 73 | <mo stretchy="true" form="prefix">[</mo> |
| 74 | <mtext mathvariant="normal">end</mtext> |
| 75 | <mo stretchy="true" form="postfix">]</mo> |
| 76 | </mrow> |
| 77 | <mo>=</mo> |
| 78 | <mrow> |
| 79 | <mo stretchy="true" form="prefix">(</mo> |
| 80 | <msub> |
| 81 | <mi>x</mi> |
| 82 | <mi>f</mi> |
| 83 | </msub> |
| 84 | <mrow> |
| 85 | <mo stretchy="true" form="prefix">[</mo> |
| 86 | <mtext mathvariant="normal">end</mtext> |
| 87 | <mo stretchy="true" form="postfix">]</mo> |
| 88 | </mrow> |
| 89 | <mo>,</mo> |
| 90 | <msub> |
| 91 | <mi>y</mi> |
| 92 | <mi>f</mi> |
| 93 | </msub> |
| 94 | <mrow> |
| 95 | <mo stretchy="true" form="prefix">[</mo> |
| 96 | <mtext mathvariant="normal">end</mtext> |
| 97 | <mo stretchy="true" form="postfix">]</mo> |
| 98 | </mrow> |
| 99 | <mo stretchy="true" form="postfix">)</mo> |
| 100 | </mrow> |
| 101 | <mo>,</mo> |
| 102 | <msub> |
| 103 | <mi>v</mi> |
| 104 | <mi>f</mi> |
| 105 | </msub> |
| 106 | <mrow> |
| 107 | <mo stretchy="true" form="prefix">[</mo> |
| 108 | <mtext mathvariant="normal">end</mtext> |
| 109 | <mo stretchy="true" form="postfix">]</mo> |
| 110 | </mrow> |
| 111 | <mo>,</mo> |
| 112 | <msub> |
| 113 | <mi>a</mi> |
| 114 | <mi>f</mi> |
| 115 | </msub> |
| 116 | <mrow> |
| 117 | <mo stretchy="true" form="prefix">[</mo> |
| 118 | <mtext mathvariant="normal">end</mtext> |
| 119 | <mo stretchy="true" form="postfix">]</mo> |
| 120 | </mrow> |
| 121 | <mo stretchy="true" form="postfix">)</mo> |
| 122 | </mrow> |
| 123 | </mrow> |
| 124 | <annotation encoding="application/x-tex">q_{f}\left\lbrack \text{end} \right\rbrack = \left( |
| 125 | p_{f}\left\lbrack \text{end} \right\rbrack = \left( x_{f}\left\lbrack \text{end} |
| 126 | \right\rbrack,y_{f}\left\lbrack \text{end} \right\rbrack \right),v_{f}\left\lbrack \text{end} |
| 127 | \right\rbrack,a_{f}\left\lbrack \text{end} \right\rbrack \right)</annotation> |
| 128 | </semantics> |
| 129 | </math> |
| 130 | (returned from the physical modeling from the last section, |
| 131 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 132 | <semantics> |
| 133 | <msub> |
| 134 | <mo>⋅</mo> |
| 135 | <mi>f</mi> |
| 136 | </msub> |
| 137 | <annotation encoding="application/x-tex">\cdot_{f}</annotation> |
| 138 | </semantics> |
| 139 | </math> |
| 140 | signifies that we are looking at the filtered output) |
| 141 | </p> |
| 142 | </li> |
| 143 | <li> |
| 144 | <p><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 145 | <semantics> |
| 146 | <msub> |
| 147 | <mi>K</mi> |
| 148 | <mtext mathvariant="normal">max</mtext> |
| 149 | </msub> |
| 150 | <annotation encoding="application/x-tex">K_{\text{max}}</annotation> |
| 151 | </semantics> |
| 152 | </math> |
| 153 | max number of iterations |
| 154 | (<code>sampling_end_of_stroke_max_iterations</code>)</p> |
| 155 | </li> |
| 156 | <li> |
| 157 | <p><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 158 | <semantics> |
| 159 | <msub> |
| 160 | <mi>Δ</mi> |
| 161 | <mtext mathvariant="normal">target</mtext> |
| 162 | </msub> |
| 163 | <annotation encoding="application/x-tex">\Delta_{\text{target}}</annotation> |
| 164 | </semantics> |
| 165 | </math> |
| 166 | the target time delay between stroke |
| 167 | (1/<code>sampling_min_output_rate</code>)</p> |
| 168 | </li> |
| 169 | <li> |
| 170 | <p><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 171 | <semantics> |
| 172 | <msub> |
| 173 | <mi>d</mi> |
| 174 | <mtext mathvariant="normal">stop</mtext> |
| 175 | </msub> |
| 176 | <annotation encoding="application/x-tex">d_{\text{stop}}</annotation> |
| 177 | </semantics> |
| 178 | </math> |
| 179 | stopping distance |
| 180 | (<code>sampling_end_of_stroke_stopping_distance</code>)</p> |
| 181 | </li> |
| 182 | <li> |
| 183 | <p><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 184 | <semantics> |
| 185 | <msub> |
| 186 | <mi>k</mi> |
| 187 | <mtext mathvariant="normal">spring</mtext> |
| 188 | </msub> |
| 189 | <annotation encoding="application/x-tex">k_{\text{spring}}</annotation> |
| 190 | </semantics> |
| 191 | </math> |
| 192 | and |
| 193 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 194 | <semantics> |
| 195 | <msub> |
| 196 | <mi>k</mi> |
| 197 | <mtext mathvariant="normal">drag</mtext> |
| 198 | </msub> |
| 199 | <annotation encoding="application/x-tex">k_{\text{drag}}</annotation> |
| 200 | </semantics> |
| 201 | </math> |
| 202 | the modeling coefficients |
| 203 | </p> |
| 204 | </li> |
| 205 | </ul> |
| 206 | <p><strong>initialize</strong> the vector |
| 207 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 208 | <semantics> |
| 209 | <msub> |
| 210 | <mi>q</mi> |
| 211 | <mi>o</mi> |
| 212 | </msub> |
| 213 | <annotation encoding="application/x-tex">q_{o}</annotation> |
| 214 | </semantics> |
| 215 | </math> |
| 216 | with |
| 217 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 218 | <semantics> |
| 219 | <mrow> |
| 220 | <msub> |
| 221 | <mi>q</mi> |
| 222 | <mn>0</mn> |
| 223 | </msub> |
| 224 | <mo stretchy="false" form="prefix">[</mo> |
| 225 | <mn>0</mn> |
| 226 | <mo stretchy="false" form="postfix">]</mo> |
| 227 | <mo>=</mo> |
| 228 | <mrow> |
| 229 | <mrow> |
| 230 | <mo stretchy="true" form="prefix">(</mo> |
| 231 | <munder> |
| 232 | <munder> |
| 233 | <mrow> |
| 234 | <msub> |
| 235 | <mi>p</mi> |
| 236 | <mi>f</mi> |
| 237 | </msub> |
| 238 | <mrow> |
| 239 | <mo stretchy="true" form="prefix">[</mo> |
| 240 | <mtext mathvariant="normal">end</mtext> |
| 241 | <mo stretchy="true" form="postfix">]</mo> |
| 242 | </mrow> |
| 243 | </mrow> |
| 244 | <mo accent="true">⏟</mo> |
| 245 | </munder> |
| 246 | <mrow> |
| 247 | <msub> |
| 248 | <mi>p</mi> |
| 249 | <mi>o</mi> |
| 250 | </msub> |
| 251 | <mo stretchy="false" form="prefix">[</mo> |
| 252 | <mn>0</mn> |
| 253 | <mo stretchy="false" form="postfix">]</mo> |
| 254 | </mrow> |
| 255 | </munder> |
| 256 | <mo>,</mo> |
| 257 | <munder> |
| 258 | <munder> |
| 259 | <mrow> |
| 260 | <msub> |
| 261 | <mi>v</mi> |
| 262 | <mi>f</mi> |
| 263 | </msub> |
| 264 | <mrow> |
| 265 | <mo stretchy="true" form="prefix">[</mo> |
| 266 | <mtext mathvariant="normal">end</mtext> |
| 267 | <mo stretchy="true" form="postfix">]</mo> |
| 268 | </mrow> |
| 269 | </mrow> |
| 270 | <mo accent="true">⏟</mo> |
| 271 | </munder> |
| 272 | <mrow> |
| 273 | <msub> |
| 274 | <mi>v</mi> |
| 275 | <mi>o</mi> |
| 276 | </msub> |
| 277 | <mo stretchy="false" form="prefix">[</mo> |
| 278 | <mn>0</mn> |
| 279 | <mo stretchy="false" form="postfix">]</mo> |
| 280 | </mrow> |
| 281 | </munder> |
| 282 | <mo>,</mo> |
| 283 | <munder> |
| 284 | <munder> |
| 285 | <mrow> |
| 286 | <msub> |
| 287 | <mi>a</mi> |
| 288 | <mi>f</mi> |
| 289 | </msub> |
| 290 | <mrow> |
| 291 | <mo stretchy="true" form="prefix">[</mo> |
| 292 | <mtext mathvariant="normal">end</mtext> |
| 293 | <mo stretchy="true" form="postfix">]</mo> |
| 294 | </mrow> |
| 295 | </mrow> |
| 296 | <mo accent="true">⏟</mo> |
| 297 | </munder> |
| 298 | <mrow> |
| 299 | <msub> |
| 300 | <mi>a</mi> |
| 301 | <mn>0</mn> |
| 302 | </msub> |
| 303 | <mo stretchy="false" form="prefix">[</mo> |
| 304 | <mn>0</mn> |
| 305 | <mo stretchy="false" form="postfix">]</mo> |
| 306 | </mrow> |
| 307 | </munder> |
| 308 | <mo stretchy="true" form="postfix">)</mo> |
| 309 | </mrow> |
| 310 | </mrow> |
| 311 | </mrow> |
| 312 | <annotation encoding="application/x-tex">q_{0}\lbrack 0\rbrack = \left. \left( \underset{p_{o}\lbrack |
| 313 | 0\rbrack}{\underbrace{p_{f}\left\lbrack \text{end} \right\rbrack}},\underset{v_{o}\lbrack |
| 314 | 0\rbrack}{\underbrace{v_{f}\left\lbrack \text{end} \right\rbrack}},\underset{a_{0}\lbrack |
| 315 | 0\rbrack}{\underbrace{a_{f}\left\lbrack \text{end} \right\rbrack}} \right) \right.</annotation> |
| 316 | </semantics> |
| 317 | </math><br /> |
| 318 | <strong>initialize</strong> |
| 319 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 320 | <semantics> |
| 321 | <mrow> |
| 322 | <mi>Δ</mi> |
| 323 | <mi>t</mi> |
| 324 | <mo>=</mo> |
| 325 | <msub> |
| 326 | <mi>Δ</mi> |
| 327 | <mtext mathvariant="normal">target</mtext> |
| 328 | </msub> |
| 329 | </mrow> |
| 330 | <annotation encoding="application/x-tex">\Delta t = \Delta_{\text{target}}</annotation> |
| 331 | </semantics> |
| 332 | </math><br /> |
| 333 | <strong>for</strong> |
| 334 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 335 | <semantics> |
| 336 | <mrow> |
| 337 | <mn>1</mn> |
| 338 | <mo>≤</mo> |
| 339 | <mi>k</mi> |
| 340 | <mo>≤</mo> |
| 341 | <msub> |
| 342 | <mi>K</mi> |
| 343 | <mtext mathvariant="normal">max</mtext> |
| 344 | </msub> |
| 345 | </mrow> |
| 346 | <annotation encoding="application/x-tex">1 \leq k \leq K_{\text{max}}</annotation> |
| 347 | </semantics> |
| 348 | </math><br /> |
| 349 | - <strong>calculate</strong> the next candidate |
| 350 | <math display="block" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 351 | <semantics> |
| 352 | <mtable> |
| 353 | <mtr> |
| 354 | <mtd columnalign="right" style="text-align: right"> |
| 355 | <msub> |
| 356 | <mi>a</mi> |
| 357 | <mi>c</mi> |
| 358 | </msub> |
| 359 | </mtd> |
| 360 | <mtd columnalign="left" style="text-align: left"> |
| 361 | <mo>=</mo> |
| 362 | <mfrac> |
| 363 | <mrow> |
| 364 | <mi>p</mi> |
| 365 | <mrow> |
| 366 | <mo stretchy="true" form="prefix">[</mo> |
| 367 | <mtext mathvariant="normal">end</mtext> |
| 368 | <mo stretchy="true" form="postfix">]</mo> |
| 369 | </mrow> |
| 370 | <mo>−</mo> |
| 371 | <msub> |
| 372 | <mi>p</mi> |
| 373 | <mi>o</mi> |
| 374 | </msub> |
| 375 | <mrow> |
| 376 | <mo stretchy="true" form="prefix">[</mo> |
| 377 | <mtext mathvariant="normal">end</mtext> |
| 378 | <mo stretchy="true" form="postfix">]</mo> |
| 379 | </mrow> |
| 380 | </mrow> |
| 381 | <msub> |
| 382 | <mi>k</mi> |
| 383 | <mtext mathvariant="normal">spring</mtext> |
| 384 | </msub> |
| 385 | </mfrac> |
| 386 | <mo>−</mo> |
| 387 | <msub> |
| 388 | <mi>k</mi> |
| 389 | <mrow> |
| 390 | <mtext mathvariant="normal">drag </mtext> |
| 391 | <mspace width="0.333em"></mspace> |
| 392 | </mrow> |
| 393 | </msub> |
| 394 | <msub> |
| 395 | <mi>v</mi> |
| 396 | <mn>0</mn> |
| 397 | </msub> |
| 398 | <mrow> |
| 399 | <mo stretchy="true" form="prefix">[</mo> |
| 400 | <mtext mathvariant="normal">end</mtext> |
| 401 | <mo stretchy="true" form="postfix">]</mo> |
| 402 | </mrow> |
| 403 | </mtd> |
| 404 | </mtr> |
| 405 | <mtr> |
| 406 | <mtd columnalign="right" style="text-align: right"> |
| 407 | <msub> |
| 408 | <mi>v</mi> |
| 409 | <mi>c</mi> |
| 410 | </msub> |
| 411 | </mtd> |
| 412 | <mtd columnalign="left" style="text-align: left"> |
| 413 | <mo>=</mo> |
| 414 | <msub> |
| 415 | <mi>v</mi> |
| 416 | <mi>o</mi> |
| 417 | </msub> |
| 418 | <mo stretchy="false" form="prefix">[</mo> |
| 419 | <mn>0</mn> |
| 420 | <mo stretchy="false" form="postfix">]</mo> |
| 421 | <mo>+</mo> |
| 422 | <mi>Δ</mi> |
| 423 | <mi>t</mi> |
| 424 | <msub> |
| 425 | <mi>a</mi> |
| 426 | <mi>c</mi> |
| 427 | </msub> |
| 428 | </mtd> |
| 429 | </mtr> |
| 430 | <mtr> |
| 431 | <mtd columnalign="right" style="text-align: right"> |
| 432 | <msub> |
| 433 | <mi>p</mi> |
| 434 | <mi>c</mi> |
| 435 | </msub> |
| 436 | </mtd> |
| 437 | <mtd columnalign="left" style="text-align: left"> |
| 438 | <mo>=</mo> |
| 439 | <msub> |
| 440 | <mi>p</mi> |
| 441 | <mi>o</mi> |
| 442 | </msub> |
| 443 | <mo stretchy="false" form="prefix">[</mo> |
| 444 | <mn>0</mn> |
| 445 | <mo stretchy="false" form="postfix">]</mo> |
| 446 | <mo>+</mo> |
| 447 | <mi>Δ</mi> |
| 448 | <msub> |
| 449 | <mi>v</mi> |
| 450 | <mi>c</mi> |
| 451 | </msub> |
| 452 | </mtd> |
| 453 | </mtr> |
| 454 | </mtable> |
| 455 | <annotation encoding="application/x-tex">\begin{aligned} |
| 456 | a_{c} & = \frac{p\left\lbrack \text{end} \right\rbrack - p_{o}\left\lbrack \text{end} |
| 457 | \right\rbrack}{k_{\text{spring}}} - k_{\text{drag }}v_{0}\left\lbrack \text{end} \right\rbrack \\ |
| 458 | v_{c} & = v_{o}\lbrack 0\rbrack + \Delta ta_{c} \\ |
| 459 | p_{c} & = p_{o}\lbrack 0\rbrack + \Delta v_{c} |
| 460 | \end{aligned}</annotation> |
| 461 | </semantics> |
| 462 | </math> |
| 463 | </p> |
| 464 | <p><br /> |
| 465 | - <strong>if</strong> |
| 466 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 467 | <semantics> |
| 468 | <mrow> |
| 469 | <mrow> |
| 470 | <mo>∥</mo> |
| 471 | <mrow> |
| 472 | <msub> |
| 473 | <mi>p</mi> |
| 474 | <mi>c</mi> |
| 475 | </msub> |
| 476 | <mo>−</mo> |
| 477 | <mi>p</mi> |
| 478 | <mrow> |
| 479 | <mo stretchy="true" form="prefix">[</mo> |
| 480 | <mtext mathvariant="normal">end</mtext> |
| 481 | <mo stretchy="true" form="postfix">]</mo> |
| 482 | </mrow> |
| 483 | </mrow> |
| 484 | </mrow> |
| 485 | <mo>∥</mo> |
| 486 | <mo><</mo> |
| 487 | <msub> |
| 488 | <mi>d</mi> |
| 489 | <mtext mathvariant="normal">stop</mtext> |
| 490 | </msub> |
| 491 | </mrow> |
| 492 | <annotation encoding="application/x-tex">\left. \parallel{p_{c} - p\left\lbrack \text{end} \right\rbrack} |
| 493 | \right.\parallel < d_{\text{stop}}</annotation> |
| 494 | </semantics> |
| 495 | </math> |
| 496 | (further iterations won’t be able to catch up and won’t move closer to |
| 497 | the anchor, we stop here), - <strong>return</strong> |
| 498 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 499 | <semantics> |
| 500 | <msub> |
| 501 | <mi>q</mi> |
| 502 | <mn>0</mn> |
| 503 | </msub> |
| 504 | <annotation encoding="application/x-tex">q_{0}</annotation> |
| 505 | </semantics> |
| 506 | </math><br /> |
| 507 | - <strong>endif</strong><br /> |
| 508 | </p> |
| 509 | <ul> |
| 510 | <li> |
| 511 | <p><strong>if</strong> |
| 512 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 513 | <semantics> |
| 514 | <mrow> |
| 515 | <mo stretchy="false" form="prefix">⟨</mo> |
| 516 | <msub> |
| 517 | <mi>p</mi> |
| 518 | <mi>c</mi> |
| 519 | </msub> |
| 520 | <mo>−</mo> |
| 521 | <msub> |
| 522 | <mi>p</mi> |
| 523 | <mi>o</mi> |
| 524 | </msub> |
| 525 | <mrow> |
| 526 | <mo stretchy="true" form="prefix">[</mo> |
| 527 | <mtext mathvariant="normal">end</mtext> |
| 528 | <mo stretchy="true" form="postfix">]</mo> |
| 529 | </mrow> |
| 530 | <mo>,</mo> |
| 531 | <mi>p</mi> |
| 532 | <mrow> |
| 533 | <mo stretchy="true" form="prefix">[</mo> |
| 534 | <mtext mathvariant="normal">end</mtext> |
| 535 | <mo stretchy="true" form="postfix">]</mo> |
| 536 | </mrow> |
| 537 | <mo>−</mo> |
| 538 | <msub> |
| 539 | <mi>p</mi> |
| 540 | <mi>o</mi> |
| 541 | </msub> |
| 542 | <mrow> |
| 543 | <mo stretchy="true" form="prefix">[</mo> |
| 544 | <mtext mathvariant="normal">end</mtext> |
| 545 | <mo stretchy="true" form="postfix">]</mo> |
| 546 | </mrow> |
| 547 | <mo stretchy="false" form="postfix">⟩</mo> |
| 548 | <mo><</mo> |
| 549 | <mrow> |
| 550 | <mo>∥</mo> |
| 551 | <mrow> |
| 552 | <msub> |
| 553 | <mi>p</mi> |
| 554 | <mi>c</mi> |
| 555 | </msub> |
| 556 | <mo>−</mo> |
| 557 | <msub> |
| 558 | <mi>p</mi> |
| 559 | <mi>o</mi> |
| 560 | </msub> |
| 561 | <mrow> |
| 562 | <mo stretchy="true" form="prefix">[</mo> |
| 563 | <mtext mathvariant="normal">end</mtext> |
| 564 | <mo stretchy="true" form="postfix">]</mo> |
| 565 | </mrow> |
| 566 | </mrow> |
| 567 | </mrow> |
| 568 | <mo>∥</mo> |
| 569 | </mrow> |
| 570 | <annotation encoding="application/x-tex">\langle p_{c} - p_{o}\left\lbrack \text{end} |
| 571 | \right\rbrack,p\left\lbrack \text{end} \right\rbrack - p_{o}\left\lbrack \text{end} |
| 572 | \right\rbrack\rangle < \left. \parallel{p_{c} - p_{o}\left\lbrack \text{end} \right\rbrack} |
| 573 | \right.\parallel</annotation> |
| 574 | </semantics> |
| 575 | </math> |
| 576 | (we’ve overshot the anchor, we retry with a smaller step) |
| 577 | </p> |
| 578 | <p><br /> |
| 579 | </p> |
| 580 | <ul> |
| 581 | <li> |
| 582 | <p><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 583 | <semantics> |
| 584 | <mrow> |
| 585 | <mi>Δ</mi> |
| 586 | <mi>t</mi> |
| 587 | <mo>←</mo> |
| 588 | <mfrac> |
| 589 | <mrow> |
| 590 | <mi>Δ</mi> |
| 591 | <mi>t</mi> |
| 592 | </mrow> |
| 593 | <mn>2</mn> |
| 594 | </mfrac> |
| 595 | </mrow> |
| 596 | <annotation encoding="application/x-tex">\Delta t \leftarrow \frac{\Delta t}{2}</annotation> |
| 597 | </semantics> |
| 598 | </math>,</p> |
| 599 | </li> |
| 600 | <li> |
| 601 | <p><strong>continue</strong> (this candidate will be discarded, try |
| 602 | again with a smaller time step instead),</p> |
| 603 | </li> |
| 604 | </ul> |
| 605 | </li> |
| 606 | </ul> |
| 607 | <p>- <strong>else</strong><br /> |
| 608 | - |
| 609 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 610 | <semantics> |
| 611 | <mrow> |
| 612 | <msub> |
| 613 | <mi>q</mi> |
| 614 | <mn>0</mn> |
| 615 | </msub> |
| 616 | <mo stretchy="false" form="prefix">[</mo> |
| 617 | <mi>e</mi> |
| 618 | <mi>n</mi> |
| 619 | <mi>d</mi> |
| 620 | <mspace width="0.222em"></mspace> |
| 621 | <mo>+</mo> |
| 622 | <mn>1</mn> |
| 623 | <mo stretchy="false" form="postfix">]</mo> |
| 624 | <mo>=</mo> |
| 625 | <mrow> |
| 626 | <mo stretchy="true" form="prefix">(</mo> |
| 627 | <msub> |
| 628 | <mi>p</mi> |
| 629 | <mi>c</mi> |
| 630 | </msub> |
| 631 | <mo>,</mo> |
| 632 | <msub> |
| 633 | <mi>v</mi> |
| 634 | <mi>c</mi> |
| 635 | </msub> |
| 636 | <mo>,</mo> |
| 637 | <msub> |
| 638 | <mi>q</mi> |
| 639 | <mi>c</mi> |
| 640 | </msub> |
| 641 | <mo stretchy="true" form="postfix">)</mo> |
| 642 | </mrow> |
| 643 | </mrow> |
| 644 | <annotation encoding="application/x-tex">q_{0}\lbrack end\ +1\rbrack = \left( p_{c},v_{c},q_{c} \right) |
| 645 | </annotation> |
| 646 | </semantics> |
| 647 | </math> |
| 648 | (We append the result to the end of the |
| 649 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 650 | <semantics> |
| 651 | <msub> |
| 652 | <mi>q</mi> |
| 653 | <mn>0</mn> |
| 654 | </msub> |
| 655 | <annotation encoding="application/x-tex">q_{0}</annotation> |
| 656 | </semantics> |
| 657 | </math> |
| 658 | vector)<br /> |
| 659 | - <strong>endif</strong><br /> |
| 660 | </p> |
| 661 | <ul> |
| 662 | <li> |
| 663 | <p><strong>if</strong> |
| 664 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 665 | <semantics> |
| 666 | <mrow> |
| 667 | <mrow> |
| 668 | <mo>∥</mo> |
| 669 | <mrow> |
| 670 | <msub> |
| 671 | <mi>p</mi> |
| 672 | <mi>c</mi> |
| 673 | </msub> |
| 674 | <mo>−</mo> |
| 675 | <mi>p</mi> |
| 676 | <mrow> |
| 677 | <mo stretchy="true" form="prefix">[</mo> |
| 678 | <mtext mathvariant="normal">end</mtext> |
| 679 | <mo stretchy="true" form="postfix">]</mo> |
| 680 | </mrow> |
| 681 | </mrow> |
| 682 | </mrow> |
| 683 | <mo>∥</mo> |
| 684 | <mo><</mo> |
| 685 | <msub> |
| 686 | <mi>d</mi> |
| 687 | <mtext mathvariant="normal">stop</mtext> |
| 688 | </msub> |
| 689 | </mrow> |
| 690 | <annotation encoding="application/x-tex">\left. \parallel{p_{c} - p\left\lbrack \text{end} |
| 691 | \right\rbrack} \right.\parallel < d_{\text{stop}}</annotation> |
| 692 | </semantics> |
| 693 | </math>, |
| 694 | </p> |
| 695 | <ul> |
| 696 | <li> |
| 697 | <p><strong>return</strong> (We are within tolerance of the anchor, |
| 698 | we stop iterating),</p> |
| 699 | </li> |
| 700 | </ul> |
| 701 | </li> |
| 702 | <li> |
| 703 | <p><strong>endif</strong>,</p> |
| 704 | </li> |
| 705 | </ul> |
| 706 | <p><strong>Output</strong> : |
| 707 | <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> |
| 708 | <semantics> |
| 709 | <mrow> |
| 710 | <mo stretchy="true" form="prefix">{</mo> |
| 711 | <msub> |
| 712 | <mi>q</mi> |
| 713 | <mi>o</mi> |
| 714 | </msub> |
| 715 | <mo stretchy="false" form="prefix">[</mo> |
| 716 | <mi>k</mi> |
| 717 | <mo stretchy="false" form="postfix">]</mo> |
| 718 | <mo>=</mo> |
| 719 | <mrow> |
| 720 | <mo stretchy="true" form="prefix">(</mo> |
| 721 | <msub> |
| 722 | <mi>s</mi> |
| 723 | <mi>o</mi> |
| 724 | </msub> |
| 725 | <mo stretchy="false" form="prefix">[</mo> |
| 726 | <mi>k</mi> |
| 727 | <mo stretchy="false" form="postfix">]</mo> |
| 728 | <mo>,</mo> |
| 729 | <msub> |
| 730 | <mi>v</mi> |
| 731 | <mi>o</mi> |
| 732 | </msub> |
| 733 | <mo stretchy="false" form="prefix">[</mo> |
| 734 | <mi>k</mi> |
| 735 | <mo stretchy="false" form="postfix">]</mo> |
| 736 | <mo>,</mo> |
| 737 | <msub> |
| 738 | <mi>a</mi> |
| 739 | <mi>o</mi> |
| 740 | </msub> |
| 741 | <mo stretchy="false" form="prefix">[</mo> |
| 742 | <mi>k</mi> |
| 743 | <mo stretchy="false" form="postfix">]</mo> |
| 744 | <mo stretchy="true" form="postfix">)</mo> |
| 745 | </mrow> |
| 746 | <mo>,</mo> |
| 747 | <mn>0</mn> |
| 748 | <mo>≤</mo> |
| 749 | <mi>k</mi> |
| 750 | <mo>≤</mo> |
| 751 | <mi>n</mi> |
| 752 | <mrow> |
| 753 | <mo stretchy="true" form="prefix">(</mo> |
| 754 | <mo>≤</mo> |
| 755 | <msub> |
| 756 | <mi>K</mi> |
| 757 | <mrow> |
| 758 | <mtext mathvariant="normal">max </mtext> |
| 759 | <mspace width="0.333em"></mspace> |
| 760 | </mrow> |
| 761 | </msub> |
| 762 | <mo>−</mo> |
| 763 | <mn>1</mn> |
| 764 | <mo stretchy="true" form="postfix">)</mo> |
| 765 | </mrow> |
| 766 | <mo stretchy="true" form="postfix">}</mo> |
| 767 | </mrow> |
| 768 | <annotation encoding="application/x-tex">\left\{ q_{o}\lbrack k\rbrack = \left( s_{o}\lbrack |
| 769 | k\rbrack,v_{o}\lbrack k\rbrack,a_{o}\lbrack k\rbrack \right),0 \leq k \leq n\left( \leq K_{\text{max }} |
| 770 | - 1 \right) \right\}</annotation> |
| 771 | </semantics> |
| 772 | </math> |
| 773 | </p> |