/* See interval.h */ /* Last edited on 2005-02-04 02:57:00 by stolfi */ #include void interval_widen(interval_t *r, double margin) { r->end[0] = r->end[0] - margin; r->end[1] = r->end[1] + margin; } void interval_adjust_ratio(interval_t *xr, interval_t *yr, double tx, double ty) { double dx = xr->end[1] - xr->end[0]; double dy = yr->end[1] - yr->end[0]; if (ty*dx > tx*dy) { double ey = (ty*dx/tx - dy)/2.0; yr->end[0] = yr->end[0] - ey; yr->end[1] = yr->end[1] + ey; } else if (ty*dx < tx*dy) { double ex = (tx*dy/ty - dx)/2.0; xr->end[0] = xr->end[0] - ex; xr->end[1] = xr->end[1] + ex; } }