# Ben NanoNote 3D scans Commit Details

Date: 2010-09-24 22:28:48 (9 years 2 months ago) Werner Almesberger 2764155d15eeca9715b2428fa8653cc35ed7cb79 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 solidify/overlap.c (1 diff) solidify/style.h (1 diff)

## Change Details

solidify/overlap.c
362362    int dy = event->y-sy(s)/2;
363363    double r = hypot(dx, dy);
364364    double rc = r_center(s);
365    double rs, rot;
365366    int center = r < rc;
366367    int osd = osd_proximity(s, dx, dy);
367368
368369    if (r < 1)
369370        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
370389    switch (event->direction) {
371390    case GDK_SCROLL_UP:
372391        if (center)
373392            shift(&s->a->m, dx, dy, 1);
374393        else
375            rotate(&s->a->m, dx > 0 ? r : -r);
394            rotate(&s->a->m, dx > 0 ? rot : -rot);
376395        draw_image(darea, s, osd);
377396        break;
378397    case GDK_SCROLL_DOWN:
379398        if (center)
380399            shift(&s->a->m, dx, dy, -1);
381400        else
382            rotate(&s->a->m, dx > 0 ? -r : r);
401            rotate(&s->a->m, dx > 0 ? -rot : rot);
383402        draw_image(darea, s, osd);
384403        break;
385404    default:
solidify/style.h
2323#define LEVEL_CENTER_DIV 5 /* fraction of diagonal */
2424#define OVERLAP_BORDER 10 /* pixels around min. drawing area */
2525#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 */
2628
2729
2830void init_style(GdkDrawable *da);

Branches:
master