Ben NanoNote 3D scans
Sign in or create your account | Project List | Help
Ben NanoNote 3D scans Commit Details
Date: | 2010-09-24 22:28:48 (9 years 2 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | 2764155d15eeca9715b2428fa8653cc35ed7cb79 |
Message: | Increase dynamic range of rotation and follow "far from center
= faster" paradigm. - solidify/overlap.c (scroll_event): make weighting of rotation exponential, so we can both adjust precisely and spin rapidly. Also reverse weighting to rotate more quickly on the outside. - solidify/style.h (SLOWEST_ROT, FASTEST_ROT): parameters for weighting of rotation |
Files: |
solidify/overlap.c (1 diff) solidify/style.h (1 diff) |
Change Details
solidify/overlap.c | ||
---|---|---|
362 | 362 | int dy = event->y-sy(s)/2; |
363 | 363 | double r = hypot(dx, dy); |
364 | 364 | double rc = r_center(s); |
365 | double rs, rot; | |
365 | 366 | int center = r < rc; |
366 | 367 | int osd = osd_proximity(s, dx, dy); |
367 | 368 | |
368 | 369 | if (r < 1) |
369 | 370 | return TRUE; |
371 | ||
372 | /* | |
373 | * rot goes exponentially from SLOWEST_ROT*rs to FASTEST_ROT for | |
374 | * r = rc to rs, with rs being half the canvas diagonal. | |
375 | * | |
376 | * The values are picked such that we achieve sufficient precision at | |
377 | * a reasonably large distance from the circle (for accidently entering | |
378 | * the circle would change the mode) but can also spin quickly, e.g., | |
379 | * when a 180 degrees rotation is needed. | |
380 | * | |
381 | * First, normalize to 0 ... 1 | |
382 | * Then, we start at exp(0) and end at | |
383 | * exp(ln(SLOWEST_ROT*rs/FASTEST_ROT))) | |
384 | */ | |
385 | rs = hypot(sx(s), sy(s))/2; | |
386 | rot = (r-rc)/(rs-rc); | |
387 | rot = SLOWEST_ROT*rs*exp(-rot*log(SLOWEST_ROT*rs/FASTEST_ROT)); | |
388 | ||
370 | 389 | switch (event->direction) { |
371 | 390 | case GDK_SCROLL_UP: |
372 | 391 | if (center) |
373 | 392 | shift(&s->a->m, dx, dy, 1); |
374 | 393 | else |
375 | rotate(&s->a->m, dx > 0 ? r : -r); | |
394 | rotate(&s->a->m, dx > 0 ? rot : -rot); | |
376 | 395 | draw_image(darea, s, osd); |
377 | 396 | break; |
378 | 397 | case GDK_SCROLL_DOWN: |
379 | 398 | if (center) |
380 | 399 | shift(&s->a->m, dx, dy, -1); |
381 | 400 | else |
382 | rotate(&s->a->m, dx > 0 ? -r : r); | |
401 | rotate(&s->a->m, dx > 0 ? -rot : rot); | |
383 | 402 | draw_image(darea, s, osd); |
384 | 403 | break; |
385 | 404 | default: |
solidify/style.h | ||
---|---|---|
23 | 23 | #define LEVEL_CENTER_DIV 5 /* fraction of diagonal */ |
24 | 24 | #define OVERLAP_BORDER 10 /* pixels around min. drawing area */ |
25 | 25 | #define OVERLAP_CENTER_DIV 5 /* fraction of diagonal */ |
26 | #define SLOWEST_ROT 3 /* thrice the half-diagonal */ | |
27 | #define FASTEST_ROT 2 /* one pixel in distance of 2 pixels */ | |
26 | 28 | |
27 | 29 | |
28 | 30 | void init_style(GdkDrawable *da); |
Branches:
master